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 Shield from Semtech.
While cleaning-out my code, something unexpected appeared 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.
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