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

Temperature read on nRF52811 SDK_15.3

So I looked at the example of the temprature read and I got the following code:

NRF_TEMP->TASKS_START = 1; /** Start the temperature measurement. */

/* Busy wait while temperature measurement is not finished, you can skip waiting if you enable interrupt for DATARDY event and read the result in the interrupt. */
/*lint -e{845} // A zero has been given as right argument to operator '|'" */
while (NRF_TEMP->EVENTS_DATARDY == 0)
{
    // Do nothing. //THIS HERE IS THE TROUBLE!!!!
}
NRF_TEMP->EVENTS_DATARDY = 0;

/**@note Workaround for PAN_028 rev2.0A anomaly 29 - TEMP: Stop task clears the TEMP register. */
temp = (nrf_temp_read() / 4);

/**@note Workaround for PAN_028 rev2.0A anomaly 30 - TEMP: Temp module analog front end does not power down when DATARDY event occurs. */
NRF_TEMP->TASKS_STOP = 1; /** Stop the temperature measurement. */

NRF_LOG_INFO("Actual temperature: %d", (int)temp);

But the problem I got is with the: while (NRF_TEMP->EVENTS_DATARDY == 0), I don't want to keep checking a while loop for and risk getting stuck here for like all time!

Also how many measurements does NRF_TEMP->TASKS_START = 1; /** Start the temperature measurement. */ take. I ask this cause I want also to be power efficient.

What would be the best approach to stay power efficient and avoid the risk of getting stuck in a while loop.

Regards,

Ameer Usman

Parents Reply Children
No Data
Related