accessing the nRF5340 temperature sensor

Hi,

I have a couple of questions regarding reading the nRF5340 Temperature Sensor.

This is a follow-up to the following DevZone ticket:  https://devzone.nordicsemi.com/f/nordic-q-a/120345/sw-got-stuck-during-reading-internal-temp-sensor

 Our app needs to read the die temperature, so based on that ticket, we have to rely on the measurement already requested by MPSL.

1) At what interval is the temperature sensor accessed by the BT Controller and/or MPSL?  The other DevZone ticket mentions 8 seconds.  Is there an exact interval? 

2) Is the interval related to the CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_PERIOD, CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP, and any other CONFIG?  

3) If so to #2, can we calculate the exact interval? If so, which CONFIG would be best to adjust to, for example, change the interval to 5 seconds?

4) If I'm in DTM mode while in idle state, the die temperature seems to be running at 2.5-3 degrees Celsius higher than in BT mode (in idle state). Is this expected?  This observation was made when using the nRF5340DK, but we see the same difference with our custom HW.

5) Is the following #if macro check correct to conditionalize reading the temperature value directly from the register?

   uint8_t temp;

#if defined(CONFIG_MPSL) && defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION)
   /* we are expecting the MPSL library to read the temperature every x secs */

   temp = nrf_temp_result_get( NRF_TEMP ); /* return value is in increments of 0.25 celsius */
#else
   int count = 0;

   /* start temperature measurement */
   nrf_temp_task_trigger( NRF_TEMP, NRF_TEMP_TASK_START );

   /* wait for the data to be ready */
   while( !nrf_temp_event_check( NRF_TEMP, NRF_TEMP_EVENT_DATARDY ) )
   {
      count++; /* avg counter value when reading the temperature is 140 */

      /* break out of the while loop if counter > 200 so that we don't get stuck */
      if ( count > 200 )
      {
         break;
      }
   }

   temp = nrf_temp_result_get( NRF_TEMP ); /* return value is in increments of 0.25 celsius */

   /* stop the temperature measurement and clear the data ready bit */
   nrf_temp_task_trigger( NRF_TEMP, NRF_TEMP_TASK_STOP );
   nrf_temp_event_clear( NRF_TEMP, NRF_TEMP_EVENT_DATARDY );
#endif

Thanks in advance!

Related