標(biāo)題: 藍(lán)牙4.0與51的程序 [打印本頁]

作者: 海闊天空a    時間: 2016-6-28 22:48
標(biāo)題: 藍(lán)牙4.0與51的程序

#include <reg52.h>
#include <intrins.h>
double tmp;
unsigned int c=0;
void init();
void send(double a);
void ctrl()

void main()
{
                init();
          while(1)
          {         
                  if(RI==1)                  
                  {
                   RI = 0;
                  tmp = SBUF;                 
                                  send(tmp);
                                  }      
          }
}

void init()
{
                  ES=0;                                                       
                  SCON = 0x50;                     

                  TMOD = 0x20;                     
          TH1=TL1=0xFD;                     

          PCON &= 0x7f;                     
          TR1 = 1;                                               
                                                                                         
                  TI=0;                                                                 
                  RI=0;
                  
                  //EA=0;
              ES=1;

}

void send(double a)
{                                               
        TI=0;       
        SBUF=a;
        while(TI==0);
        TI=0;
}







歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1