nrf51822 --- 内部温度传感器

来源:互联网 发布:西北工业大学网络远程 编辑:程序博客网 时间:2024/04/30 01:36

1.目的

      利用温度传感器来获得芯片的温度

2.分析

   nrf51822自带一个温度传感器,nrf51822可以利用这个温度稳定传感器来矫正晶体,具体看nrf51822 ---协议栈时钟源选择(32.768khz)

用户自己同过温度,获得周围环境变化的趋势以及,保护板子的

3.平台:

协议栈版本:SDK10.0.0

编译软件:keil 5.14

硬件平台:nrf51822最小系统

例子:SDK 10.0.0\examples\ble_peripheral\ble_app_uart\pca10028\s110\arm4

4.步骤

1.首先看下温度的参数,功耗,测量时间,测量范围,精确度,测量精度0.25度

  参考手册:《nRF51822_PS v3.1.pdf》



2.通过在协议里面调用这个函数可以获得温度的值,把这个获得的值除以4就是测出的温度。。

/**@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));
3.初略的计算下温度值。值保留整数部分

  

void Get_tempure(void){ int32_t  temp;    sd_temp_get(&temp);    SEGGER_RTT_printf(0,"Actual temperature: %d\n\r", (int)(temp/4));}
在main()函数中

   

  // Enter main loop.    for (;;)    {    //添加的温度代码    Get_tempure();        power_manage();    }
运行结果如下。。  OK



0 0
原创粉丝点击