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

nRF52 will not sleep after NFC event

I have an application (with SD S212) that uses NFC. Ideally, the processor would be in idle most of the time, waking up only to FIELDDETECTED and FIELDLOST events.

The processor starts off sleeping fine (consuming the proper amount of current, about 3uA), and wakes up when the NFC reader approaches. All the functionality is fine, except it never sleeps again. It enters the sd_app_evt_wait() and will not leave until another NFC event (or other event), but the current draw is not the idle current draw (~3mA).

I am not in debug, so as far as I'm concerned, the device should not consume this much during "idle".

Here is my NFC handler:

void nfc_callback(void *context, NfcEvent event, const char *data, size_t dataLength)
{
(void)context;

switch (event)
{
    case NFC_EVENT_FIELD_ON:						
					NRF_NFCT->EVENTS_FIELDDETECTED = 0;
        break;
    case NFC_EVENT_FIELD_OFF:
					NRF_NFCT->EVENTS_FIELDLOST = 0;
        break;
    default:
        break;
}	
}

This is my loop in main:

// Main loop. 
for (;;)
{          
			// Put CPU in sleep if possible. 
			err_code = sd_app_evt_wait();
			APP_ERROR_CHECK(err_code);

}

It actually does things during the NFC handler, but commenting those out makes no effect on the current draw, so I don't believe they are the culprit - hence why I took them out.

I guess there is a pending event or something that the SD does not consider important enough to return for, but at the same time will not sleep because of. But I'm not entirely sure if there is something I should be clearing. I know it is not reentering the nfc_callback.

Without NFC my code operates as I expect (sleep and all).

Hopefully someone has some suggestions :)

Related