|
Sapozhnik posted:well, shifting by more than the word size is also undefined. on some arches you get zero, on others the high-order bits of the shift parameter are ignored. that's a feature, mapping a language feature to an arch feature is what C is for if you don't like it, use a better language, like most of them
|
# ? Jul 5, 2017 02:32 |
|
|
# ? Jun 3, 2024 23:44 |
|
yeah like java, where >> means arithmetic right shift, a thing you'd want to do, ever logical right shift is >>>
|
# ? Jul 5, 2017 03:02 |
|
Cybernetic Vermin posted:common lisp has a great standard as well, but it came out when lisp was already passing out of relevance heresy, Common Lisp is quite relevant I've run it on an Intel Edison and I run it on Raspberry Pi and classic Macs a fraction the speed and it works great (yeah yeah yeah real world relevance etc. but if you're just doing hobby poo poo you can use what you what and CL can fit right into that, as can Haskell and anything else)
|
# ? Jul 5, 2017 03:43 |
|
Cybernetic Vermin posted:nah, the c standard is one of the few reasonably complete language standards not entirely bound to a single implementation. javascript and c++ are the only other of relevance i can think of (common lisp has a great standard as well, but it came out when lisp was already passing out of relevance) the ANSI C standard from 1989 is why I was able to download the latest mbedTLS and libssh2 source code and get them building on a 2002 iMac G4 running Mac OS 9.2.2, doing nothing that (in principle) wouldn't also compile on a Mac Plus running System 6 (modulo code size, mbedTLS compiles to about 1MB of code)
|
# ? Jul 5, 2017 03:48 |
|
that said I certainly wouldn't consider the C standard anywhere near "complete" given how many kinds of undefined and implementation-defined behavior it has, but the parts that are defined have turned out to be reasonably portable
|
# ? Jul 5, 2017 03:50 |
|
eschaton posted:the ANSI C standard from 1989 is why I was able to download the latest mbedTLS and libssh2 source code and get them building on a 2002 iMac G4 running Mac OS 9.2.2, doing nothing that (in principle) wouldn't also compile on a Mac Plus running System 6 (modulo code size, mbedTLS compiles to about 1MB of code) uh, i use mbed-tls on a cortex m3 that definitely does not have 1mb of flash
|
# ? Jul 5, 2017 03:53 |
|
yeah, I'm just building everything in right now, including self-test, if I say I want to put data in "ROM" (actually Mac resources) and don't include self-test I bet it'll get plenty smaller even with all the cipher suites and such included
|
# ? Jul 5, 2017 08:54 |
|
spent a couple of hours checking the continuity of an improvised wire harness and trying to debug a chip I couldn't talk to over SPI until my coworker thought to ask "are you sure you're connecting to the right SPI bus?" I was not
|
# ? Jul 6, 2017 16:52 |
|
just got tasked with enabling LED PWM support on the board I'm working with. this board has been through 6 revisions over the course of 2 full years. And it's basically just a poo poo microcontroller, a few knobs, and a couple of LEDs. turns out that even on the current revision, I can't use the microcontroller PWM because the only way to actually make the LED driver circuit work is to set the pin to an input and toggle the pullup resistor on and off. JESUE loving CHRIST
|
# ? Jul 8, 2017 19:18 |
|
can you even toggle the pullup that fast?
|
# ? Jul 8, 2017 19:20 |
|
haha
|
# ? Jul 8, 2017 19:20 |
|
hobbesmaster posted:can you even toggle the pullup that fast? probably not
|
# ? Jul 8, 2017 19:23 |
|
for extra lols, the LED brightness winds up depending on the value of the pullup (which goes from 50% to 200% of nominal) and also the transistor gain (which can be anywhere from 40 to 300) if the transistor gain is high enough, the circuit doesn't work at all Poopernickel fucked around with this message at 19:27 on Jul 8, 2017 |
# ? Jul 8, 2017 19:25 |
|
jfc i'm pretty sure i could do a better job than that and i've never designed a pcb before in my life
|
# ? Jul 8, 2017 19:28 |
|
usually if it's just an indicator LED you can get away with driving it right off the microcontroller's gpio, no need for any external buffer circuit. even the current limit resistor is optional since most uC output drivers can't source more than 10 to 20 mA and if you have to put in a transistor for higher current it should be a fet imo, lol @ using a pair of bjts for this application
|
# ? Jul 8, 2017 19:55 |
|
Poopernickel posted:
what were they even going for here? if it's something like a 5mm LED you can do it literally as GPIO -> resistor -> LED -> ground why is there one transistor driving the LED and another transistor to drive that transistor (also is this a darlington pair?)? i guess i could see that being a thing if the LED is too powerful for the GPIO directly, and you picked some terrible drive transistor that needs more current to saturate than the microcontroller can provide? mosfets or bust Sagebrush fucked around with this message at 20:04 on Jul 8, 2017 |
# ? Jul 8, 2017 20:01 |
|
only reason I can come up with for that bullshit is that they're driving it from a 3.3V micro and have to high-side switch because the LED in question is a red/green common cathode LED (it's still garbage in the worst way) also, it's a 2-channel common-cathode led (red/green) so of course they want ~*CoLoRs*~ for marketing reasons the most ironic part is that once they dial in their magic PWM value which I'll have to provide manually with timer interrupts, the colors will change wildly from unit to unit because of this poo poo circuit "constant-current source? what's that and why would we ever need it lol" Poopernickel fucked around with this message at 20:07 on Jul 8, 2017 |
# ? Jul 8, 2017 20:05 |
|
Sagebrush posted:what were they even going for here? it's a bog-standard 5mm red/green comon cathode LED, driving it with ~15mA all of these BJTs are one-per-package SOT-23s because why place one component when you could place two instead the circuit would actually work(ish) if there was a limiting resistor between the two transistors, but as it is Q2's emitter-base current starves the LED current Poopernickel fucked around with this message at 20:14 on Jul 8, 2017 |
# ? Jul 8, 2017 20:08 |
|
that's pretty terrible, but you gotta admire that dedication to saving $0.001 by not putting in an extra resistor to make it work it's not like a SN74LVC2T45 is that expensive
|
# ? Jul 8, 2017 20:20 |
|
longview posted:that's pretty terrible, but you gotta admire that dedication to saving $0.001 by not putting in an extra resistor to make it work i would bet my left nut that it was an accident which stayed in the design through 6 revisions nobody ever noticed because the last firmware engineer on this project didn't know that he was toggling the pullup resistor rather than the output
|
# ? Jul 8, 2017 20:28 |
|
Poopernickel posted:i would bet my left nut that it was an accident which stayed in the design through 6 revisions i was about to ask how but then I realized the registers are probably separated by a letter or something
|
# ? Jul 8, 2017 20:32 |
|
hobbesmaster posted:i was about to ask how but then I realized the registers are probably separated by a letter or something it's the direction register that makes the difference - On the Attiny88 and friends, the 'value' register controls the pullup resistor if the pin is an input and it's an input by default unless you set the pin to an output
|
# ? Jul 8, 2017 20:39 |
|
i am so spoiled by cmsis its not funny edit: er, technically vendor specific hals
|
# ? Jul 8, 2017 20:41 |
|
why does anybody use atmel for anything it was an iffy choice even before microchip bought them out and jacked up all the prices 500% like it's not a bad 8-bit architecture by any means, it's just that we live in the year 2017 and cost-competitive 32-bit microcontrollers which can be targeted by the same compilers that see massive use for desktop and server applications are things that exist
|
# ? Jul 8, 2017 22:25 |
|
arduinos
|
# ? Jul 8, 2017 23:34 |
|
probably cause you can still get avrs in 5v DIP packages that are easy to mess around with, and they do the job for a lot of dumb little things and unlike PIC their toolchain isn't garbage
|
# ? Jul 8, 2017 23:35 |
|
Sapozhnik posted:why does anybody use atmel for anything ikr
|
# ? Jul 8, 2017 23:38 |
|
Sagebrush posted:they do the job for a lot of dumb little things and unlike PIC their toolchain isn't garbage this, and also msp430's toolchain is pretty good too but in tyool 2017, there are m0+'s on the market that are on-par power-consumption wise, can compute a lot more, and are even cheaper sometimes Poopernickel fucked around with this message at 23:42 on Jul 8, 2017 |
# ? Jul 8, 2017 23:40 |
|
You can get NXP cm0 chips in dip packaging Lol nothing you interface with is gonna be 5v grandpa
|
# ? Jul 8, 2017 23:55 |
|
Sapozhnik posted:jfc i'm pretty sure i could do a better job than that and i've never designed a pcb before in my life I'm pretty sure I could do a better job and I've basically never done or tried to do analog how does one fail so spectacularly at blinking a loving LED? (it reminds me of the analog-component-packed XNOR board Radio-Electronics published for their April Fool's issue one year in the late 1980s, it filled a 3x5 board and "only a few hundred of these and you can make a simple ALU!")
|
# ? Jul 9, 2017 08:12 |
|
Sapozhnik posted:why does anybody use atmel for anything I was thinking about using a sha256 authentication chip from them. Seems cheap and would be nice for storing a private key yes? Is there another company/chip I should look at? Edit: Something like this: http://www.microchip.com/wwwproducts/en/ATSHA204A#buy 50c~ per unit seems ok. FlapYoJacks fucked around with this message at 13:09 on Jul 9, 2017 |
# ? Jul 9, 2017 12:47 |
|
BobHoward posted:usually if it's just an indicator LED you can get away with driving it right off the microcontroller's gpio, no need for any external buffer circuit. even the current limit resistor is optional since most uC output drivers can't source more than 10 to 20 mA a current rating doesn't imply any form of current limiting by any means; those CMOS logic output drivers provide low-impedance paths from ground/VCC to the output when you put them on logic 0/1 so omitting the current-limiting resistor will cause it to briefly source a very large current until it and/or the LED both burn out. therefore it's up to you to obey the current rating they'd be pretty lovely outputs if they worked any other way tbh edit: I once accidentally hooked up a PIC wrong and didn't understand why it wasn't working properly until I smelled the burning plastic scent of the breadboard under the chip, and then burned my finger touching it micro still worked after but that particular pin was screwed up BattleMaster fucked around with this message at 13:27 on Jul 9, 2017 |
# ? Jul 9, 2017 13:16 |
|
the current limit is kind of there anyway for HC logic since the output drive transistors are physically tiny and so the on resistance is very large different logic families have different maximum currents, HC logic is only actually good up to 4mA so they can't really drive a LED at full current (and will probably drive a LED directly since the output transistors are real wimps). LVC/LCX logic is much faster and can drive more current (up to 32mA depending on supply voltage). TTL logic is even shittier and usually they have asymmetric output impedances with terrible sourcing capabilities. this is part of why i use a pleasing shade of orange for all my LEDs unless absolutely necessary; they light up sufficiently for office environments at less than 1mA.
|
# ? Jul 9, 2017 13:59 |
|
ratbert90 posted:I was thinking about using a sha256 authentication chip from them. Seems cheap and would be nice for storing a private key yes? there's also gemalto secure element but they don't publicly release much. probably because they're used to selling SIM cards
|
# ? Jul 9, 2017 19:55 |
|
ratbert90 posted:I was thinking about using a sha256 authentication chip from them. Seems cheap and would be nice for storing a private key yes? atmel is fine for that stuff, I think he meant don't gently caress wit no AVR when you can use an m0 instead
|
# ? Jul 9, 2017 23:29 |
|
longview posted:the current limit is kind of there anyway for HC logic since the output drive transistors are physically tiny and so the on resistance is very large yeah it's this i was thinking of, most cmos gpios on µCs are just going to self limit. it's an iffy thing to do but you can sometimes get away with it. not recommended for mass production a better low component count option is inverse logic: connect the µC gpio to the LED cathode, and vcc to a current limit resistor to the LED anode. microcontroller gpios can often sink much more than they can source, and if the µC supports open/drain outputs, this trick lets you run the led from a higher voltage than the microcontroller's vcc
|
# ? Jul 10, 2017 00:01 |
|
BobHoward posted:yeah it's this i was thinking of, most cmos gpios on µCs are just going to self limit. it's an iffy thing to do but you can sometimes get away with it. not recommended for mass production yep this is the way to go -- drive LEDs with a "____LED_B" signal and call it a day. lol i guess at the LEDs (potentially) briefly flicking while mcu is in reset / booting up $0.001 for the requisite resistor ain't no thang
|
# ? Jul 10, 2017 19:25 |
|
a modern micro should boot up with the GPIO in high-z so even that won't be an issue; I can't think of any excuse for that weird-rear end transistor circuit even if it wasn't fundamentally broken
|
# ? Jul 11, 2017 05:26 |
|
Poopernickel posted:just got tasked with enabling LED PWM support on the board I'm working with. 5
|
# ? Jul 12, 2017 02:07 |
|
|
# ? Jun 3, 2024 23:44 |
|
got what i imagine is a real simple question: assuming that the goal is to chop a large piece of data into individual bytes, is there a functional difference between byte b = (32_bit_int >> 24); and byte b = (32_bit_int >> 24) & 0xFF; ? I've seen both the bit-shifting alone and the shift-and-mask method and I dunno what is the difference.
|
# ? Jul 21, 2017 08:31 |