执行程序蜂鸣器正常响 但是建立不了文件void UART_init(void){ SCON = 0x50; //8-bit variable UART
TMOD |= 0x20; //Set timer1 as 8-bit auto reload mode TH1 = TL1 =-3;// -(FOSC/12/32/BAUD); //Set auto-reload vaule TR1 = 1; //Timer1 start run ES = 1; //Enable UART interrupt EA = 1; //Open master interrupt switch}void SendData2(uchar dat){ while(TX2_busy); TX2_busy=1;
SBUF = dat;}void SendString2(char *s) //////////´òÓ¡×Ö·û´®{ while (*s) //Check the end of the string { SendData2(*s++); //Send current char and increment string ptr }}
void DelayUS(unsigned int Time){ unsigned char i; while(Time--) { for(i=0;i<20;i++); }}void Uart_Isr() interrupt 4 using 1{ if (RI) { RI = 0; //Clear receive interrupt flag Rxbuff2=SBUF; RX2_busy=0; } if (TI) { TI = 0; //Clear transmit interrupt flag TX2_busy = 0; //Clear transmit busy flag }}//////////////////////////////UÅ̳ÌÐò////////////////////////////////void xWriteCH376Cmd(uchar Cmd) // ÏòCH376дÃüÁî { SendData2(0x57); DelayUS(1000); SendData2(0xAB); DelayUS(1000); SendData2(Cmd);} void xWriteCH376Data(uchar mData) { SendData2(mData);}void main(){UART_init(); PortInit();buzzer=0; while(1) { xWriteCH376Cmd(0x06); xWriteCH376Data(0x55); if(Rxbuff2==0xaa) { DelayUS(1000); Rxbuff2=0; xWriteCH376Cmd(0x15); ///////Ñ¡ÔñUÅÌģʽ xWriteCH376Data(0x06); } if((Rxbuff2==0x51)||(Rxbuff2==0x15)) { DelayUS(1000); Rxbuff2=0; xWriteCH376Cmd(0x30); ///////¼ì²âUÅÌÊÇ·ñÁ¬½Ó DelayUS(1000); Rxbuff2=0; xWriteCH376Cmd(0x31);//////////³õʼ»¯UÅÌ
DelayUS(1000); Rxbuff2=0; xWriteCH376Cmd(0x2F); ///////´´½¨ÎļþÃüÁî SendString2("/CDE.TXT"); xWriteCH376Cmd(0x34); ///////´´½¨Îļþ DelayUS(1000); Rxbuff2=0; xWriteCH376Cmd(0x22); ////////»ñÈ¡ÖжÏ״̬ // } } if(Rxbuff2==0x56) { buzzer=1; } // } // } } }
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>