#define TM (65536 -(MAIN_Fosc/Baudrate/4))
#define Timer0_Reload (65536UL -(MAIN_Fosc / 1000)) //Timer 0 中断频率, 1000次/秒
#define Baudrate 115200UL
void UartInit(void)
{
P_SW1 = (P_SW1 & 0x3f) | 0x00; //USART1 switch to, 0x00: P3.0 P3.1, 0x40: P3.6 P3.7, 0x80: P1.6 P1.7, 0xC0: P4.3 P4.4
SCON = (SCON & 0x3f) | 0x40;
T1x12 = 1; //定时器时钟1T模式
S1BRT = 0; //串口1选择定时器1为波特率发生器
TL1 = TM;
TH1 = TM>>8;
TR1 = 1; //定时器1开始计时
}
void UartPutc(unsigned char dat)
{
SBUF = dat;
while(TI==0);
TI = 0;
}
char putchar(char c)
{
UartPutc(c);
return c;
}
stc32g12k128串口打印函数
猜你喜欢
转载自blog.csdn.net/GQ_Sonofgod/article/details/127242734
今日推荐
周排行