设为首页收藏本站

Discuz! Board

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 4387|回复: 2
打印 上一主题 下一主题

温度读取的问题

[复制链接]

3

主题

5

帖子

26

积分

新手上路

Rank: 1

积分
26
跳转到指定楼层
楼主
william 发表于 2015-11-20 12:52:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
static void ble_stack_init(void)
{
    // Initialize SoftDevice.
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
   
    // Subscribe for BLE events.
    uint32_t err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}
void get_temperature(void)
{
        NRF_TEMP->TASKS_START = 1; /**¿aê¼Î¶è2aá¿. */

        /* Busy wait while temperature measurement is not finished, you can skip waiting if you enable interrupt for DATARDY event and read the result in the interrupt. */
        /*lint -e{845} // A zero has been given as right argument to operator '|'" */
        while (NRF_TEMP->EVENTS_DATARDY == 0)            
        {
                        // Do nothing.
        }
        NRF_TEMP->EVENTS_DATARDY    = 0;  

        /**@note Workaround for PAN_028 rev2.0A anomaly 29 - TEMP: Stop task clears the TEMP register. */      
        temperature = (nrf_temp_read()/4);
        temperature=temperature*0.6904-0.74;

        /**@note Workaround for PAN_028 rev2.0A anomaly 30 - TEMP: Temp module analog front end does not power down when DATARDY event occurs. */
        NRF_TEMP->TASKS_STOP        = 1; /** Stop the temperature measurement. */
       
        log_printf("temperature = %d\n", temperature);

}


int main(void)
{
               
    nrf_temp_init();
    get_temperature();
    ble_stack_init();//D-òéÕ»3õê¼»ˉ
       

}

问题:

在main 函数里面,如果temp初始化和读取在 ble_stack_init() 前面的话,读取是成功的,在 ble_stack_init() 后面的话,就报硬件错误。
在 ble_stack_init()后面, 连  nrf_temp_init() 都会错,这是怎么回事








分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

243

主题

1706

帖子

6151

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
6151
沙发
admin 发表于 2015-11-20 19:08:37 | 只看该作者
不是这样简单的加温度采样。你可以采用两种方式,方式1:把温度采集作为一个任务,设置私有任务的UUID。方式2:用蓝牙串口作为任务,温度值用蓝牙串口进行传递。
回复 支持 反对

使用道具 举报

3

主题

5

帖子

26

积分

新手上路

Rank: 1

积分
26
板凳
 楼主| william 发表于 2015-11-24 11:13:43 | 只看该作者
ble_stack_init() 后面这样读温度的话会报错,如果不是这样读,那该怎么读? 为什么会报错?
回复 支持 反对

使用道具 举报

Archiver|手机版|小黑屋|Comsenz Inc.   

GMT+8, 2024-5-3 13:35 , Processed in 0.116990 second(s), 28 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表