完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
/******************************************************************************* * ??: * * 12864???????? ??p0,??p2 * ********************************************************************************/ #include #include #include #include #define uchar unsigned char #define uint unsigned int #define FOSC_110592M /************* 12864LCD???? *************/ #define LCD_data P2 //??? ***it LCD_RS = P0^7; //??????? ***it LCD_RW = P0^6; //???/??? ***it LCD_EN = P0^5; //?????? ***it LCD_PSB = P0^4; //?/????? ***it LCD_RST = P0^3; //?????? ***it LED = P1^2; ***it wind = P0^0; ***it ds=P3^5; #define delayNOP(); {_nop_();_nop_();_nop_();_nop_();}; /*********************************************************/ uchar n,r,a,d1,d2; uchar buffer[6]; //定义数据缓存数组 void delay1ms(void); uint b,d,a1; uchar table[7]={0,0,0,0,0,0,0}; unsigned int rec_data_len_uart=0; //标记Buffer_Uart0接收数组 unsigned char idata Buffer_Uart0_Rec[25]={0}; //Uart0中断接收数? uchar code num[] = {'0','1','2','3','4','5','6','7','8','9'}; uchar code DIS1[] = {"温度是:20 safe"}; uchar code DIS2[] = {"CO浓度:10 safe"}; uchar code DIS3[] = {"粉尘为:50 safe "}; uchar code DIS4[] = {"风机:OFF "}; uchar code DIS5[] = {"safe"}; uchar code DIS6[] = {"WARN"}; uchar code DIS7[] = {"ON"}; uchar code DIS8[] = {"OFF"}; //注意,无论接收到信号还是发送完信号,都会进中断服务程序的 /*初始化程序(必须使用,否则无法收发),次程序将会使用定时器1*/ void SerialInti()//初始化程序(必须使用,否则无法收发) { TMOD=0x20;//定时器1操作模式2:8位自动重载定时器 #ifdef FOSC_12M //在这里根据晶振大小设置不同的数值初始化串口 TH1=0xf3;//装入初值,波特率2400 TL1=0xf3; #else TH1=0xfd;//装入初值,波特率9600 TL1=0xfd; #endif //end of SOC_12M TR1=1;//打开定时器 SM0=0;//设置串行通讯工作模式,(10为一部发送,波特率可变,由定时器1的溢出率控制) SM1=1;//(同上)在此模式下,定时器溢出一次就发送一个位的数据 REN=1;//串行接收允许位(要先设置sm0sm1再开串行允许) EA=1;//开总中断 ES=1;//开串行口中断 } unsigned char hand(unsigned char *data_source,unsigned char *ptr) { if(strstr(data_source,ptr)!=NULL) return 1; else return 0; } void clear_rec_data() { uchar i,temp_len; temp_len=strlen(Buffer_Uart0_Rec); if(temp_len>25) { temp_len=25; } for(i=0;i Buffer_Uart0_Rec=' |