前言

温度传感器测量芯片DIE温度。通过触发START任务来启动TEMP。当温度测量完成后,一个数据将生成事件,并且可以从临时寄存器读取测量结果为了保证测量的准确性,必须在选择HFCLK晶体振荡器作为时钟。当温度测量完成后,将温度模拟电路的电源降下来可以节省电能。TEMP只支持一次性操作,这意味着必须显式地开始使用每个TEMP度量一开始的任务。

本节将介绍nRF51系列SOC片上温度传感器的使用,并通过串口把采集到的芯片内部的温度打印到PC端nRF51的ADC设计得比较简单,用于配置的寄存器只要一个。它有几个可配置的部分:

 

 

相关寄存器介绍

throttlestop温度设置 temp怎么调温度_throttlestop温度设置

throttlestop温度设置 temp怎么调温度_f5_02

throttlestop温度设置 temp怎么调温度_f5_03

示例详解

基于硬件平台:nrf51822ek_tm开发板。

 

throttlestop温度设置 temp怎么调温度_f5_04

本示例所用的最小系统板原理图:

throttlestop温度设置 temp怎么调温度_f5_05

throttlestop温度设置 temp怎么调温度_f5_06

 

  1. 工程创建:
  1. 打开KEIL,新建一个空工程:Project->NewuVisionProject

throttlestop温度设置 temp怎么调温度_f5_07

工程名为nrfxx-temp确认后按下图选择芯片为nrf51822_xxAA->ok

throttlestop温度设置 temp怎么调温度_throttlestop温度设置_08

在弹出的对话框中勾选CMSIS中的CORE;Device中的Startup(后面有nrf51Series字样的);在nrf_device中勾选nrf_gpio, nrf_uart, nrf_temp, nrf_delay,nrf_err并在nrf_Libraries中勾选app_error,nrf_assert模块。

 

throttlestop温度设置 temp怎么调温度_寄存器_09

throttlestop温度设置 temp怎么调温度_寄存器_10

 

 

OK之后工程自动生成如下代码:

throttlestop温度设置 temp怎么调温度_throttlestop温度设置_11

新建一个空白文档,保存为main.c,并加入工程中:

throttlestop温度设置 temp怎么调温度_寄存器_12

throttlestop温度设置 temp怎么调温度_throttlestop温度设置_13

throttlestop温度设置 temp怎么调温度_f5_14

throttlestop温度设置 temp怎么调温度_throttlestop温度设置_15

配置工程,选择使用MicroLIB库,可以减小程序体积:

throttlestop温度设置 temp怎么调温度_f5_16

加入NRF51定义,并选择化等级3,可以减小程序体积,但仿真运行时可能会出现与代码顺序不一致现象:

 

throttlestop温度设置 temp怎么调温度_throttlestop温度设置_17

调试工具选择J-LINK,并将接口设置为SW口勾选下载程序后自动复位及运行:

 

throttlestop温度设置 temp怎么调温度_f5_18

throttlestop温度设置 temp怎么调温度_throttlestop温度设置_19

throttlestop温度设置 temp怎么调温度_寄存器_20

 

  1. 工程代码
  1. OK之后在man.c中加入如下代码:

throttlestop温度设置 temp怎么调温度_寄存器_21

throttlestop温度设置 temp怎么调温度_寄存器_22

throttlestop温度设置 temp怎么调温度_寄存器_23

 

 

 

 

 

把程序编译,可以看到串口助手中打印了以下输出内容:

throttlestop温度设置 temp怎么调温度_寄存器_24