WiringProject / Wiring

Wiring Framework
http://wiring.org.co/
Other
217 stars 168 forks source link

Fix read access for 16bit timer counter registers. #6

Open ydirson opened 12 years ago

ydirson commented 12 years ago

To get meaningful reading, we must read the low byte first, so the MCU saves the correct high byte value in the counter's temporary register (see eg. section 14.2 of the 32u4 datasheet).

ydirson commented 12 years ago

Tested on my 32u4 board, on a project where I emulate several clocks on a single timer, and thus have to save/restore the timer state. Current getCounter() method just does not work.

I hope all AVR8 mcu's share the same behaviour.