Recently I was using tx_benchmark.c in the obsolete usb serial library from https://www.pjrc.com/teensy/usb_serial.html as an example for how to setup a timer on a Teensy 2.0++ in C. One thing confused me about the code, and I now believe it to be a bug (but I could certainly be mistaken). The bug is on line 37:
Code:
#define CLEAR_TIMER0_OVERFLOW() (TIFR0 |= (1<<TOV0))
I believe the or here is a bug, as TIFR0 is setup to be cleared with a write clear, where writing 1 clears the bit. Thus ORing here could end up accidentally clearing other bits out of the register leading to bugs if this timer code is reproduced elsewhere. The correct code would be:
Code:
#define CLEAR_TIMER0_OVERFLOW() (TIFR0 = (1<<TOV0))
This being said, this code is marked as Obsolete, so I shouldn't have been using it anyways, but wanted to report it for reference in case anyone else makes my mistake.