This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF52832 + SX1261 Timer goes mad

Hi all,

I successfully ported the Semtech’s LoRaMac-node (from official GitHub, master branch) to a custom assembly of two dev boards : the NRF52832 (Dev Kit PCA10040) from Nordic and the SX1261MB2BAS Arduino shield from Semtech.

While cleaning-out my code, something went wrong concerning the LoRaMac timer. As expressed in the LoRaMac porting guide, I implemented the RTC low-level driver (rtc-board.c/h). My implementation is very close to the SAML21 one, provided in the official LoRaMac-node repository. I choose to run my RTC driver with a clock source of 32768Hz (from external cristal) to respect the RX windows as close as it needs to be.

As far as I understood, when a so-called “Timer” expires, the RTC driver raises an interrupt to warn the LoRaMac timer layer. But for a reason I can’t explain, if the execution of the TimerIrqHandler takes less than two RTC clock ticks (at 32768Hz, ticks interval is approx. 30.51us), the timer layer goes mad and keeps starting new timers of 1ms each.

When I add a little delay (like 100us) juste before the TimerIrqHandler call, the node works perfectly fine, joins the network and sends packets.

Here is my RTC events handler implementation :

static void rtc_event_handler(nrf_drv_rtc_int_type_t int_type)
{
    /* RTC reached set value */
    if ( int_type == NRF_DRV_RTC_INT_COMPARE0 )
    {
        /* Whithout this delay, timer goes mad */
        nrf_delay_us(100);

        /* Call LoRaMac timer's IRQ handler */
        TimerIrqHandler( );
    }

    /* RTC reached overflow */
    else if ( int_type == NRF_DRV_RTC_INT_OVERFLOW )
    {
        u32TimestampBase += nrf_drv_rtc_max_ticks_get( &RtcObject.Instance ) / RTC_FREQUENCY;
    }
}

Has anyone experienced something similar ?
Thanks a lot for your help !

Regards,
Raphael

Parents
  • Hello,

    What are you doing in your TimerIrqHandler()? 

     

    the timer layer goes mad and keeps starting new timers of 1ms each.

     What do you mean by "timer layer" and "goes mad"? I assume "goes mad" refers to "keeps starting new timers of 1ms each", but is that the rtc? Do you use the app_timer, or one of the TIMERX (X = 0, 1, 2, 3, 4 or 5)?

    Best regards,

    Edvin

Reply
  • Hello,

    What are you doing in your TimerIrqHandler()? 

     

    the timer layer goes mad and keeps starting new timers of 1ms each.

     What do you mean by "timer layer" and "goes mad"? I assume "goes mad" refers to "keeps starting new timers of 1ms each", but is that the rtc? Do you use the app_timer, or one of the TIMERX (X = 0, 1, 2, 3, 4 or 5)?

    Best regards,

    Edvin

Children
No Data
Related