|
我用N76E003AT20單片機通過串口0發(fā)送數(shù)字1到PC,PC端一直顯示FF,這是為什么?下面是我的代碼。
#include "n76e003.h"
#include "stdio.h"
#define uint32 unsigned int
sbit s1 = P0^0;
void UART0_Init(uint32 Baud)
{
P0M1=0x84; P0M2=0x7B;
P1M1=0x00; P1M2=0xFF;
EA=1;
ES=1;
SCON = 0x52; //模式1 REN=1 TI=1
TMOD|= 0x20; //定時器1模式2
PCON|= 0x80; //使能雙波特率
CKCON|= 0x10; //定時器1為系統(tǒng)時鐘 T1M=1
T3CON&= 0xDF; //選擇定時器1
TH1=256-(1037500/Baud+1);
TR1=1; //定時器1啟動
}
int main()
{
UART0_Init(9600);
s1=1;
while(1)
{
if(s1==0)
{printf("%d\n",1);}
}
}
|
|