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

Thread: Teensy 4.1 seconds interrupt

  1. #1
    Member JaredReabow's Avatar
    Join Date
    May 2020
    Location
    oxford , UK
    Posts
    57

    Teensy 4.1 seconds interrupt

    with T3.6:
    ///seconds timer interrupt
    RTC_IER |= 0x10; // Enable seconds IRQ from RTC peripheral
    NVIC_ENABLE_IRQ(IRQ_RTC_SECOND); // Enable seconds IRS function in NVIC
    /// end of second timer interrupt

    will call the function called: rtc_seconds_isr() every second, can someone clue me in on how to do this with the t4/4.1

    I would also like an interrupt ever millisecond, 500ms etc, how can I go about pulling this off?

    Thanks.

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,317
    Use an interval timer.
    Code:
    #include <IntervalTimer.h>
    IntervalTimer int_tmr;
    .
    .
    void fn_int_tmr(void)
    {
    // Interrupt code here
    }
    
    // define the interrupt rate in HZ
    // e.g. 8kHz
    int rate_HZ = 8000;
    void setup(void)
    {
    .
    .
        int_tmr.begin(fn_int_tmr,1000000/rate_HZ);
    .
    .
    }
    
    void loop(void)
    {
    .
    .
    }
    Pete

Posting Permissions

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