- UID
- 131652
- 性别
- 男
|
请教一个HCS128的SCI0与PC通讯的问题: 在PC上用超级终端和串口调试软件上接收的数据都不对,为什么呢?
unsigned char chr;
void main(void) {
unsigned char string[]="ABCDEFGH";
int i;
SCI_Init();
for (;;){
for(i=0;i<8;i++)
{
chr=string;
SCI0Output_char (chr);
}
//EnableInterrupts;
}
}
void SCI_Init(void) {
SCI0CR2 = 0x0c; // enable T and R
SCI0BDH = 0x00;
SCI0BDL = 0x9c; // sci0 for 9600
}
void SCI0Input_char(unsigned char ch)
{
while(!(SCI0SR1&0x20))
{
}
ch=SCI0DRL;
}
void SCI0Output_char(unsigned char ch)
{
while(!(SCI0SR1&0x80))
{
}
SCI0DRL = ch;
}
|
你好,我是刚开始学习单片机的菜鸟,希望能得到帮助,谢谢!! |
|