Teensy 3.2 T3 timng different from Mega

Status
Not open for further replies.

wa1hco

New member
Hello all,

The TimerThree interrupt goes off at 1/2 the programmed time on Teensy 3.2, but works ok on Mega.
I think this is a bug report but maybe I missed something.

The attached test program tests the TimerThree when used in a delay mode.
T1 interrupt routine enters at 120 Hz, then programs the T3 interrupt for 1000 usec later.
The T1 interrupt interval is exactly correct.
T3 interrupt routine then turns off the T3 interrupt and waits for the next T1 interrupt.

This test program sets the T3 delay to 1000 usec but the T3 interrupt actually occurs in 502 usec.

The idea for this is to accept an interrupt at the AC line zero crossing at 8333 usec interval (120 Hz),
then program T3 interrupt for a variable delay in the range 100 to 8300 usec.
The second interrupt will trigger a TRIAC for phase control of AC power.

The TimerThree.h file did need to be modified to prevent an instant interrupt.
The "TODO" message is correct about the spurious interrupt
The spurious goes away by setting initial TCNT3 = 1.
TimerThree.h looks like this.
...
//****************************
// Run Control
//****************************
void start() __attribute__((always_inline)) {
TCCR3B = 0;
// initial count increased from 0 to 1 to prevent spurious IRQ
TCNT3 = 1; // TODO: does this cause an undesired interrupt?
resume();
}
...

Ideas?

jeff, wa1hco
 

Attachments

  • Timer1and3Test.ino
    2.9 KB · Views: 37
Status
Not open for further replies.
Back
Top