⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rf24e1.lst

📁 基于无线单片机24e1的组网程序。在无线传感器之类的应用中的成功案例。
💻 LST
📖 第 1 页 / 共 2 页
字号:
 152          //input:none
 153          //output:none
 154          //================================================================
 155          void IO_Init(void)
 156          {
 157   1              P0_ALT = 0x06;                                          // Select alternate functions on pins P0.1 and P0.2,  TXD RXD 
 158   1              P0_DIR = 0x00;                          // P0 work as output
 159   1              P0 = 0xff;                              // all hight    
 160   1                  P1_DIR = 0x03;                                              // P0.0, P0.3 is input(S3, S4),
 161   1             
 162   1      }
 163          
 164          /*****************************************************************************************
 165          //函数名:SendC()
 166          //输入:发送的数据
 167          //输出:无
 168          //功能描述:串口发送
 169          /*****************************************************************************************/
 170          void SendCh(char c)
 171          {
 172   1              TI = 0;
 173   1              SBUF = c;
 174   1              while(!TI);
 175   1              TI = 0;
 176   1      } 
 177          /*****************************************************************************************
C51 COMPILER V7.08   RF24E1                                                                08/17/2006 14:22:14 PAGE 4   

 178          //函数名:show_word()
 179          //输入:发送的数据int 
 180          //输出:无
 181          //功能描述:以16进制显示一个整型
 182          /*****************************************************************************************/
 183          void show_hex(char sByte)
 184          {
 185   1              if(sByte>=0 && sByte<=9)
 186   1              sByte +='0';
 187   1              else
 188   1              sByte=sByte+'A'-10;
 189   1              SendCh(sByte);
 190   1      }
 191          /*****************************************************************************************
 192          //函数名:show_word()
 193          //输入:发送的数据int 
 194          //输出:无
 195          //功能描述:以16进制显示一个整型
 196          /*****************************************************************************************/
 197          void show_word(unsigned int dat)
 198          {
 199   1              unsigned char char_temp1,char_temp2;
 200   1              char_temp1=dat>>8;
 201   1              char_temp2=char_temp1>>4;
 202   1              show_hex(char_temp2);
 203   1              char_temp2=char_temp1&0x0f;
 204   1              show_hex(char_temp2);
 205   1              char_temp1=dat&0x00ff;
 206   1              char_temp2=char_temp1>>4;
 207   1              show_hex(char_temp2);
 208   1              char_temp2=char_temp1&0x0f;
 209   1              show_hex(char_temp2);
 210   1      }
 211          
 212          //================================================================
 213          //main()>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 214          //================================================================
 215          main()
 216          {       unsigned char char_temp,data_show[5],jj;
 217   1              IO_Init();                                      //端口初始化
 218   1              InitSerial();                           //串口初始化
 219   1              Timer0_Init();                          //初始化定时器0
 220   1              fRfInit();                                      //无线子系统初始化
 221   1              while(1)
 222   1              {       Led_Show=1;                                                             //Led off
 223   2                      led=1;
 224   2                      while(RxPack()!=4);                                             //接收错误,等待有正确的数据到来
 225   2                                                                                                      //接收远方4个通道的采样值,在RxMsg_list[]数组理。
 226   2                              
 227   2                                                                                                      //收到的采样值是经过远方校正过的16位整形。
 228   2                      
 229   2                      
 230   2                      Led_Show=0;                                                     //LED on        
 231   2                      led=0;
 232   2              /*      for(char_temp=0;char_temp<4;char_temp++)
 233   2                      {       SendCh(char_temp+0x30+1);
 234   2                              SendCh('#');
 235   2                              data_show[0]=RxMsg_list[char_temp]/1000+0x30;
 236   2                              data_show[1]='.';
 237   2                              data_show[2]=(RxMsg_list[char_temp]%1000)/100+0x30;
 238   2                              data_show[3]=(RxMsg_list[char_temp]%100)/10+0x30;
 239   2                              data_show[4]=RxMsg_list[char_temp]%10+0x30;
C51 COMPILER V7.08   RF24E1                                                                08/17/2006 14:22:14 PAGE 5   

 240   2                              for(jj=0;jj<5;jj++)
 241   2                              {
 242   2                                      SendCh(data_show[jj]);
 243   2                              }
 244   2                              SendCh('V');
 245   2                      }
 246   2              */      Delayms(5);             
 247   2              }                               
 248   1              
 249   1      }
*** WARNING C280 IN LINE 216 OF RF24E1.C: 'char_temp': unreferenced local variable
*** WARNING C280 IN LINE 216 OF RF24E1.C: 'data_show': unreferenced local variable
*** WARNING C280 IN LINE 216 OF RF24E1.C: 'jj': unreferenced local variable
 250          
 251          //================================================================
 252          //函数功能:TIMER0初始化函数
 253          //filename:     Timer0_Iint()
 254          //input: none
 255          //output:none
 256          //================================================================
 257          void Timer0_Init(void)
 258          {
 259   1      
 260   1              TR0 = 0;
 261   1              TMOD &= ~0x03;
 262   1              TMOD |= 0x01;                               // mode 1
 263   1              CKCON |= 0x08;                              // T0M = 1 (/4 timer clock)
 264   1              TF0 = 0;                                    // Clear any pending Timer0 interrupts
 265   1              TH0=0xb1;
 266   1              TL0=0xe0;                                       
 267   1              TR0 = 1;                                    // Start Timer0
 268   1              ET0 = 1;                                    // Enable Timer0 interrupt
 269   1      }
 270          //================================================================
 271          //函数功能:TIMER0中断服务程序(实现1秒定时)
 272          //filename:
 273          //input: none
 274          //output:none
 275          //================================================================
 276          void Timer0_isr(void) interrupt 1
 277          {    TF0 = 0; 
 278   1               TH0=0xb1;
 279   1               TL0=0xe0;                                      //reload the counter
 280   1               Clr_Dog=~Clr_Dog;
 281   1               if(++OneSCnt==200)                     //2SECOND gain
 282   1               {
 283   2                      OneSecondGain=1;
 284   2                      OneSCnt=0;
 285   2      //              Led_Show=~Led_Show;
 286   2               }
 287   1        
 288   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    352    ----
   CONSTANT SIZE    =     15    ----
   XDATA SIZE       =      8    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     34       8
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
C51 COMPILER V7.08   RF24E1                                                                08/17/2006 14:22:14 PAGE 6   

   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  3 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -