Hi there,
On my application, I have multiple sensors attached to the nRF52 and I read them every 5 seconds scheduling the read inside a timer handler, then when the Softdevice have free time slots I got the scheduler event (now the main context) where I call my routine to enable Twi, do Twi reads/writes and finally disabling Twi.
My basics are:
define a timer per sensor
define a scheduler per sensor
handle the scheduler per sensor
call my Twi routine from the main context
But my program gets stuck passed some time, then I used app_sched_queue_space_get() and app_sched_queue_utilization_get() to look what happens inside the scheduler
space: 5 utilization: 1
space: 4 utilization: 2
space: 3 utilization: 3
space: 2 utilization: 4
space: 1 utilization: 5
then the program crash
when I add a small delay to the TWI uninitialization app_sched_queue_space_get() and app_sched_queue_utilization_get() returns for 2 sensors and the program works fine
space: 5 utilization: 1
space: 5 utilization: 2
space: 5 utilization: 2
space: 5 utilization: 2
space: 5 utilization: 2
I am disabling Twi in the following way: (because I am using gpiote too)
nrf_drv_twi_disable(&m_twi_master); nrf_drv_twi_uninit(&m_twi_master); NRF_TWI1->TASKS_STOP = 1; NRF_TWI1->ENABLE = TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos; NRF_TWI1->INTENCLR =(TWI_INTENCLR_STOPPED_Disabled << TWI_INTENCLR_STOPPED_Pos) | \ (TWI_INTENCLR_RXDREADY_Disabled << TWI_INTENCLR_RXDREADY_Pos) | \ (TWI_INTENCLR_TXDSENT_Disabled << TWI_INTENCLR_TXDSENT_Pos) | \ (TWI_INTENCLR_ERROR_Disabled << TWI_INTENCLR_ERROR_Pos) | \ (TWI_INTENCLR_BB_Disabled << TWI_INTENCLR_BB_Pos); //https://infocenter.nordicsemi.com/index.jsp?topic=%2Ferrata_nRF52832_Rev2%2FERR%2FnRF52832%2FRev2%2Flatest%2Fanomaly_832_89.html&cp=3_1_1_0_1_26 //[89] GPIOTE: Static 400 µA current while using GPIOTE *(volatile uint32_t *)0x40003FFC = 0; *(volatile uint32_t *)0x40003FFC; *(volatile uint32_t *)0x40003FFC = 1;
why I am experimenting that behavior? I dont want add delays in my program but at least it is solving that issue at the moment
my program only calls app_sched_event_put inside the timer handler and exits from it very quickly also it exits very quickly from the scheduler handler
Regards,
Arepa