為什么我的程序編譯成功了,但是串口2卻不會發送數據呢?謝謝!
- #include<STC12C5A60S2.h>
- #include <stdio.h>
- #include <string.h>
- #include<intrins.h>
- #include "UART2.h"
- #define uchar unsigned char
- #define uint unsigned int
- uchar code dis_tab1[]={" 識別結果 "};
- uchar code dis_tab4[]={"------------------------"};
- uchar RecDate[14]={0}; //串口接收 數據
- uint count_ms=0; //計時
- uchar recnum2=0; //串口接收長度
- uchar disflag=0;//顯示模式
- bit recfinish=0; //串口接收完成為1
- void Timer0Init(void) //10m秒@11.0592MHz
- {
- TMOD &= 0xF0; //設置定時器模式
- TMOD |= 0x01; //設置定時器模式
- TL0 = 0x00; //設置定時初值
- TH0 = 0xDC; //設置定時初值
- TF0 = 0; //清除TF0標志
- TR0 = 0; //定時器0關閉計時
- ET0=1;
- EA=1;
- }
- /* 串行通信初始化*/
- void UartInit(void) //9600bps@11.0592MHz
- {
- PCON &= 0x7F; //波特率不倍速
- SCON = 0x50; //8位數據,可變波特率
- TMOD &= 0x0F; //清除定時器1模式位
- TMOD |= 0x20; //設定定時器1為8位自動重裝方式
- TL1 = 0xfd; //設定定時初值
- TH1 = 0xfd; //設定定時器重裝值
- ET1 = 0; //禁止定時器1中斷
- TR1 = 1; //啟動定時器1
- ES = 1; //Enable UART1 interrupt
- EA=1; //開總中斷
-
- }
- /************************************************/
- void Delay_1ms(unsigned int xms)
- {
- unsigned int i,j;
- for(i=xms;i>0;i--)
- for(j=122;j>0;j--);
- }
復制代碼
|