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

TWI causing nRF52 not to sleep

I am using sd_app_evt_wait() to put my nRF52 to sleep. Works fine except after I read from a TWI sensor. As soon as I do I see the nRF52 continuously jump out of sleep. I have put a log into my twi_handler and except when I write to/read from the sensor, the twi_handler is not getting called, so it's not jumping out of sleep due to a nrf_drv_twi_evt_t event.

This issue only arrises when I try to read from the sensor via

 err_code = nrf_drv_twi_rx(m_twi_instance, SI7020_BASE_ADDRESS, returned_over_I2C, 3)

When I write to begin the measurement it doesn't appear to be the cause of the nRF52 not to go to sleep.

So I thought I would take a reading and then uninit twi completely until it was needed again. I added this code immediately having read from the sensor

nrf_drv_twi_uninit(&m_twi_instance);
uint32_t *twim0_power = (uint32_t *)(NRF_TWIM0_BASE+0xFFC);
*twim0_power = 0;   //turn off TWIM0
*(volatile uint32_t *)twim0_power;  

However this does not appear to work in my case, I still see the nRF52 continuously jump out of sleep.

Any thoughts?

AMENDED 1:

Here are the txt files of the registries. The first is when no TWI reading is commenced. The second is when a TWI reading has occurred and is at the point immediately below sd_app_evt_wait()

Registers when no TWI read.txt

Registers when TWI read and immediately after jumping out of sleep

AMENDED 2:

So just in case it was an fpu issue and to draw a line under this I thought I would add a power manage function along the lines suggested by this post devzone.nordicsemi.com/.../. However it appears the pack for SES does not define FPU_IRQn since I get an undefined error in SES. Any guidance how I can manually define this?

Related