Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 1 of 1

Thread: Teensy 3.2 T3 timng different from Mega

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Posts
    1

    Teensy 3.2 T3 timng different from Mega

    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
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •