- #include <STC15f2k60s2.h>
- void PZDK();
- BYTE idata UART_Num[8]={
- 0x00,0x55,0x03,0xe8,0x00,0x02,0xea,0xaa};
- BYTE idata UART_Data[16];
- BYTE JOK,JPK;
- void Delay3000ms() //@11.0592MHz
- {
- unsigned char i, j, k;
- _nop_();
- _nop_();
- i = 127;
- j = 18;
- k = 107;
- do
- {
- do
- {
- while (--k);
- } while (--j);
- } while (--i);
- }
- void main()
- {
- PZDK();
- JOK=0;
- JPK=8;
- Delay3000ms();
- S2BUF = UART_Num[0];
- while(1)
- {
-
- }
- }
- void Uart2() interrupt 8
- {
- BYTE com;
- if (S2CON & S2RI)
- {
- S2CON &= ~S2RI; //清除S2RI位
- com = S2BUF;
- }
- if (S2CON & S2ti)
- {
- S2CON &= ~S2TI;
- JOK++;
- if(JOK<JPK)
- {
- S2BUF = UART_Num[JOK];
- }
- }
- }
- void PZDK()
- {
- // P_SW2 &= ~S2_S0; //S2_S0=0 (P1.0/RxD2, P1.1/TxD2)
- P_SW2 |= S2_S0; //S2_S0=1 (P4.6/RxD2_2, P4.7/TxD2_2)
- S2CON = 0x50; //8位数据,可变波特率
- AUXR &= 0xFB; //定时器2时钟为Fosc/12,即12T
- T2L = 0xE8; //设定定时初值
- T2H = 0xFF; //设定定时初值
- AUXR |= 0x10; //启动定时器2
- IE2=0X01;
- ES = 1; //使能串口1中断
- EA = 1;
- }
复制代码Z这是个触摸屏串口
通信的测试程序
触摸屏收到0x00,0x55,0x03,0xe8,0x00,0x02,0xea,0xaa就会切换界面
在串口助手上发送这个,触摸屏正确执行,可到了
单片机,为什么就没反应了!!!!
一周热门 更多>