This is in regards to my last post here: https://devzone.nordicsemi.com/f/nordic-q-a/84016/switching-between-two-applications-using-nrf5-sdk
I am using FreeRTOS.
Both Application1 and Application2 have the same main:
int main(void)
{
log_init();
power_management_init();
APP_ERROR_CHECK(nrf_drv_clock_init());
sd_power_dcdc_mode_set(1); //use DCDC function
APP_ERROR_CHECK(nrf_drv_gpiote_init());
create_task_handler();
vTaskStartScheduler();
}
The task that is spawned/created in create_task_handler(), in Application1, immediately jumps to Application2 when I called application_start (posted in previous post).
In Application2, when debugging, I see that main is executed immediately, however the breakpoint I set at the beginning of the task that is created in create_task_handler() doesn't get hit for ~25 seconds. After about 25 seconds, the breakpoint in the created task is hit.
If I pause debugging during that 25 seconds, I see that the code is in the RTC1_IRQHandler which is xPortSysTickHandler.
I changed my application_start method to this in Application1
#include <nrf_rtc.h>
static void application_start(void)
{
// Disable interrupts
NVIC->ICER[0]=0xFFFFFFFF;
NVIC->ICPR[0]=0xFFFFFFFF;
#if defined(__NRF_NVIC_ISER_COUNT) && __NRF_NVIC_ISER_COUNT == 2
NVIC->ICER[1]=0xFFFFFFFF;
NVIC->ICPR[1]=0xFFFFFFFF;
#endif
nrf_rtc_int_disable(portNRF_RTC_REG, NRF_RTC_INT_TICK_MASK);
NVIC_ClearPendingIRQ(portNRF_RTC_IRQn);
sd_softdevice_vector_table_base_set(0x40000);
app_start(0x40000);
}
Now my application immediately jumps and Application2 starts.
Is this the correct solution--disabling RTC interrupts and clearing it before jumping? It appears to work now, but are there other interrupts I need to be wary of before jumping?
I thought setting NVIC->ICER and NVIC->ICPR to 0xFFFFFFFF was disabling interrupts--why do I have to explicitly disable and clear the RTC interrupt?