|
新手求助!使用STC8系列MCU,串口1 通訊正常!串口2死活不出信號,求助!
- #include "stc8g.h"
- #include "intrins.h"
- #include "stdio.h"
- void Uart2_Isr(void) interrupt 8
- {
- if (S2CON & 0x02) //檢測串口2發(fā)送中斷
- {
- S2CON &= ~0x02; //清除串口2發(fā)送中斷請求位
- }
- if (S2CON & 0x01) //檢測串口2接收中斷
- {
- S2CON &= ~0x01; //清除串口2接收中斷請求位
- }
- }
- void Uart2_Init(void) //115200bps@22.1184MHz
- {
- S2CON = 0x50; //8位數(shù)據(jù),可變波特率
- AUXR &= 0xFB; //定時器時鐘12T模式
- T2L = 0xFC; //設(shè)置定時初始值
- T2H = 0xFF; //設(shè)置定時初始值
- AUXR |= 0x10; //定時器2開始計時
- IE2 |= 0x01; //使能串口2中斷
- }
- void main()
- {
- Uart2_Init();
- ES = 1;
- EA = 1;
- while(1){
- printf("Uart Test !\r\n");
- }
-
- }
復(fù)制代碼
|
|