Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Interrupt based temperature sensor on nrf52840 using SDK v15.0.0

I have to implement temperature sensor readings continuously through interrupts instead of busy waiting example in SDK in order to notify those values over BLE to cloud.

I took code in below reference and compiled in SDK v15.0.0 on nrf52840.

https://devzone.nordicsemi.com/f/nordic-q-a/15729/nrf51822-tempeture-based-on-interrupt 

Below is code and issue comes after running statement NRF_TEMP->TASKS_START = 1; in main function code is going to  NRF_BREAKPOINT_COND; in app_error_fault_handler function.

What is reason and to be implemented to get it worked

static void temp_init(void){

NRF_TEMP->INTENSET |= TEMP_INTENSET_DATARDY_Enabled;
sd_nvic_SetPriority(TEMP_IRQn, APP_IRQ_PRIORITY_LOWEST);
sd_nvic_EnableIRQ(TEMP_IRQn);
}

/* Interrupt handler for TEMP data ready event */
void TEMP_IRQHandler(void){

int32_t volatile temp;

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. */

ble_temps_measurement_send(&m_temps, temp);// function to send notifications

}

int main(void)
{
nrf_temp_init();

temp_init();

// Initialisions.......

.

......
advertising_start();

NRF_TEMP->TASKS_START = 1; /** Start the temperature measurement. */
NRF_LOG_INFO("Debug logging for UART over RTT started.");

for (;;)
{
idle_state_handle();
}

}

Parents Reply Children
Related