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

NRF_TEMP peripheral and Soft Device interaction question

Hello,

I know that the NRF_TEMP peripheral is a restricted peripheral and should be accessed with the sd_temp_get function when the soft device is running. Heck I even posted in a thread about that 3 years ago. That said, that piece of knowledge eluded me while I was implementing some temperature compensation code on both an nRF51 and and nRF52. The nRF51 is using soft device v10.0.0 and the nRF52 is using soft device 132 v3.0.0.

In both cases the code is accessing NRF_TEMP->TASKS_START and DATA_READY approximately once per minute. The soft devices are enabled and running either advertising or in a connection. However, there is no hard fault or assert generated in either case counter to what I would have expected. Leading me to ask why these calls are working. Are we just getting "lucky" most of the time and we can expect random failures until we convert to the proper usage of the sd_temp_get function? Or, are there some conditions under which it just works to access the registers directly even though it is a restricted peripheral?

Thanks, John

Parents
  • When they say a peripheral is restricted, really the only thing they are saying is the SD is using it too. There is but one MCU for both softdevice and your application code. NRF_TEMP->TASKS_START is literally the pointer to the register that at some low level in the MCU drives the temp hardware. So, just because you are running the SD doesn't mean that the register is gone. It is still there and the SD is occasionally writing to it in the case of a restricted peripheral.

    Since two independent applications on the same MCU writing to the same registers in an uncoordinated fashion (you are blind to its activities just as the SD is blind to you) could result in some mishap, Nordic creates API's for all the shared use (ie, restricted peripherals). In this manner you send the SD your request for data via the API and the SD writes to the register controlling the hardware when it knows the peripheral isn't being used for something else.

    The only thing I am aware of that the SD uses the core temp feature for is calibrating the RC based RTC. If you aren't doing temp calibration of the RTC then it is probably pretty safe to write to the registers. But, whenever something is restricted you should talk to it through the API. Still best to update your code accordingly next chance you get.

  • Thanks for your thorough response. I was thinking approximately the same thing re: calibrating the RC clock which we are not doing.

Reply Children
No Data
Related