Setting a variable to 0 requires two writes?

Status
Not open for further replies.
Looking at the code, that page was written for the Teensy 2.0. The AVR processor used in the Teensy 2.0 is an 8-bit processor, so a write of a 16-bit value involved two writes. The Teensy 3.x/LC boards are 32-bit processors, and in general 8/16/32-bit values should be written with one write to memory, assuming the value is properly aligned. If the value is not aligned, it likely will take multiple writes if you are looking at the memory, and an interrupt may occur between the writes.
 
Additional question: is there a way to make sure that everything is aligned and that writes are thus atomic up to 32bit ? Doesn't the compiler do this automatically?
 
Status
Not open for further replies.
Back
Top