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

Internal temperature sensor conflicts with BLE stack?

I'm writing a program sending die temperature data through BLE. I'm trying to combine the nrf51822 Heart Rate Monitor example and the nrf6310 Temperature example. Both examples work fine.

However, if I tried to launch the temperature sensor after the initialization of BLE stack, the program will run into hard fault immediately. Debug terminates at

HardFault_Handler\
                PROC
                EXPORT  HardFault_Handler         [WEAK]
                B       .
                ENDP

Is it a hardware bug of nrf51822? Any solution?

Parents
  • The temperature sensor is a restricted peripheral when using the SoftDevice, see the S110 specification for the full list. Any access directly to this peripheral will cause a hardfault.

    If you look at nrf_soc.h, you will find the API call to get the temperature:

    /**@brief Get the temperature measured on the chip
     * 
     * This function will block until the temperature measurement is done.
     * It takes around 50us from call to return.
     *
     * @note Pan #28 in PAN-028 v 1.6 "Negative measured values are not represented correctly" is corrected by this function.
     *
     * @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees celsius.
     *
     * @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp
     */
    SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp));
    

    Cheers, Håkon

  • THANK YOU!

    I found sd_temp_get(&temp) should be used to obtain the core temperature if the softdevice is enabled. And the variable "temp" should be static. Now everything is working.

Reply Children
No Data
Related