q137226446

    1. /******************************************************************************* Filename:     18B20_sensor.c Target:       cc2530 Author:       UNique Revised:      14/7-2011 Revision:     1.1 Email:        cyliu@stu.xidian.edu.cn INFO:         把底板上的18B20管脚连接到P3的20管脚 ******************************************************************************/ /****************************************************************************** * INCLUDES */ #include "LCD3310.h" #include "ioCC2530.h" #include "DS18B20.h" /****************************************************************************** * CONSTANTS */ extern __code const unsigned char font6x8[][6]; /****************************************************************************** * TYPEDEFS */ /****************************************************************************** * GLOBAL VARIABLES */ static UINT8 ch[8]; /****************************************************************************** * LOCAL VARIABLES */ /****************************************************************************** * LOCAL FUNCTIONS */ void myApp_ReadExTemperature( void ); /****************************************************************************** * * @fn 18B20_sensor_main * * @brief * * * Parameters: * * @param  void * * @return void * ******************************************************************************/ void main(void) {    DISABLE_ALL_INTERRUPTS();    SET_MAIN_CLOCK_SOURCE(0);    initLcd();    LCD_write_english_string(0,1,"Temperature:");    LCD_write_english_string(0,3,"not calibrate");    while(1)    {     myApp_ReadExTemperature();     lcdUpdateLine(LINE1, (char *)ch);      // wait one second      halWait(250);      halWait(250);      halWait(250);      halWait(250);    } } /****************************************************************************** * @fn          myApp_ReadExTemperature * * @brief       Reports true temperature sensor reading * * @param * * @return */ void myApp_ReadExTemperature( void ) {      UINT8 temh,teml;   UINT16 num;      read_data();           // 读取温度      teml=sensor_data_value[0];   temh=sensor_data_value[1];   num=teml*625;          //小数部分的取值每位代表0.0625(精度)   if(flag==1)            //判断正负温度   {    ch[0]='-';              //+0x2d 为变"-"ASCII码   }   else ch[0]='+';      if(temh/100==0)    ch[1]=' ';   else ch[1]=temh/100+0x30;      //+0x30 为变 0~9 ASCII码   if((temh/10%10==0)&&(temh/100==0))    ch[2]=' ';   else ch[2]=temh/10+48;//%10+0x30;   ch[3]=temh%10+48;   ch[4]='.';   ch[5]=num/1000+0x30;//忽略小数点后1位的数   ch[6]='C';//忽略小数点后1位的数   ch[7]=0;//结束符 } 上面这是18b20_sensor.c程序 下面时18b20.c程序 /******************************************************************************* Filename:     DS18B20.c Target:       cc2530 Author:       UNique Revised:      14/7-2011 Revision:     1.1 Email:        cyliu@stu.xidian.edu.cn ******************************************************************************/ #include "DS18B20.h" UINT8 id[8]; UINT8 sensor_data_value[2]; UINT8 flag; void Delay_nus(UINT16 s) {   while (s--)   {     asm("NOP");     asm("NOP");     asm("NOP");   } } void init_1820(void) {   SET_OUT;   SET_DQ;//输出1   CL_DQ;   Delay_nus(550);//拉低一段时间   SET_DQ;//释放   SET_IN;//输入   Delay_nus(40); //释放总线后等待15-60us   while(IN_DQ)  {;}//等待回复   Delay_nus(240);//回复的低电平在60到240us     SET_OUT;   SET_DQ;//回到初始DQ=1; } void write_1820(UINT8 x)   {     UINT8 m;      SET_OUT;   for(m=0;m
    2. 就是cc2530通过18b20采集数据 然后通过串口传给PC机的程序
    3. cc2530AD应用的问题 2/3843 无线连接 2013-06-26
      能把采集数据的程序发来吗?

最近访客

< 1/1 >

统计信息

已有76人来访过

  • 芯积分:--
  • 好友:--
  • 主题:3
  • 回复:3

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言