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

Read Chip Temperature Sensor on nrf52832

Hello,

I am trying to read the internal temperature sensor using interrupts (SoftDevice is disabled). This is what I have:

#include "nrf_temp.h"
#include "nrf_nvic.h"

static int32_t g_temp_reading;

void TEMP_IRQHandler()
{
    NRF_TEMP->EVENTS_DATARDY = 0;
    g_temp_reading = (nrf_temp_read() / 4);
    NRF_TEMP->TASKS_STOP = 1;
}

void init()
{
    nrf_temp_init();

    g_temp_reading = 0;

    NRF_TEMP->INTENSET |= TEMP_INTENSET_DATARDY_Enabled;

    sd_nvic_SetPriority(TEMP_IRQn, APP_IRQ_PRIORITY_LOW);
    sd_nvic_EnableIRQ(TEMP_IRQn);
}

void get_temperature()
{
    NRF_TEMP->TASKS_START = 1;
}

For some reason it never gets into "TEMP_IRQHandler()"

Could you please help me understand what I am doing wrong?

Thank you in advance.

Related