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

nrf51822 tempeture based on interrupt

I can read temp value by pulling flag but I Want to do that by interrupt I added this code to my Keil but interrupt on temp didn't work. I use Adc interrupt like this definition.

static void temp_init(void){	

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

NRF_TEMP->POWER = 1 ; 
}/* 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. */

    printf(" temperature: %d\n\r", (int)temp);
}
Related