following is my code
#include <nrfx_temp.h> static void temp_handler(int32_t temperature) { m_soc_temperature = temperature; printk("Temperature (Celcius): %d \n",temperature / 4); } static void soc_temperature_peripheral_init(void) { int err; nrfx_temp_config_t temp_config = NRFX_TEMP_DEFAULT_CONFIG; err = nrfx_temp_init(&temp_config,temp_handler); IRQ_CONNECT(TEMP_IRQn,5,nrfx_temp_irq_handler,NULL,0); if (err!=NRFX_SUCCESS) { printk("soc_temperature_peripheral_init error %d\n", err); } } int main() { soc_temperature_peripheral_init(); for(;;) { k_sleep(K_SECONDS(1)); if(NRFX_SUCCESS == nrfx_temp_measure()){ LOG_INF("soc temperature is %d",m_soc_temperature/4); } } }
prj.conf file :
CONFIG_NRFX_TEMP=y