未复现,并且你的波特率计数不对?
- //#include "stc8h.h"
- //#include "def.h"
- //#include "intrins.h"
- //u8 y;
- //u8 e;
- //u8 c;
-
- //void main(){
- // c = 1;
- // y = 2;
- // e = 3;
- // while (1)
- // {
- // y = c+e;
- // c++;
- // e++;
- // }
- //}
-
- #include <STC8h.h>
- #include <intrins.h>
- #include <def.h>
-
- char putchar(char c)
- {
- SBUF = c;
- while(!TI);
- TI = 0;
- return c;
- }
-
- void Delay1000ms(void) //@30.000MHz
- {
- unsigned char data i, j, k;
-
- _nop_();
- i = 153;
- j = 49;
- k = 161;
- do
- {
- do
- {
- while (--k);
- } while (--j);
- } while (--i);
- }
-
- void Uart1_Init(void) //150000bps@30.000MHz
- {
- SCON = 0x50; //8位数据,可变波特率
- AUXR |= 0x40; //定时器时钟1T模式
- AUXR &= 0xFE; //串口1选择定时器1为波特率发生器
- TMOD &= 0x0F; //设置定时器模式
- TL1 = 0xFB; //设置定时初始值
- TH1 = 0xFF; //设置定时初始值
- ET1 = 0; //禁止定时器中断
- TR1 = 1; //定时器1开始计时
- P3M0 = 0x02; P3M1 = 0x01;
-
-
- }
-
- void main()
- {
- u8 i;
- Uart1_Init();
- Delay1000ms();
- printf("dogRST\r\n");
- for(;;)
- {
- // printf("dogRST\r\n");
- }
- }
复制代码
|