我用PE产生一个串口程序可以正常与PC通讯,
我仿照那个程序的参数自己写了个程序却不能正常与PC通讯,是乱码.
请大侠帮我看看!谢谢!
波特率9600
#include"56801.h"
typedef unsigned int word; void SCI0_SendChar(unsigned char);
void main(void) {
asm { bfset #$40,XFIU_CNTL bfset #$103F,X:ISOCTL bfclr #$FFBF,XFIU_CNTL bfclr #$FFFB,XLLCR }; while(*((word *)(PLLSR)) & 0x4 ){} asm { move #$81,XLLCR move #0,X:CLKOSR move #$11D,XLLDB }; while(!(*((word *)(PLLSR)) & 0x20)){} asm { move #$82,XLLCR bfclr #6,X:GPIO_A_PER bfset #6,X:GPIO_A_DDR bfclr #6,X:GPIO_A_DR move #0,X:SYS_CTRL orc #3,X:GPIO_B_PER move #0,X:SCI0_SCICR move #$00c3,X:SCI0_SCIBR orc #8,X:SCI0_SCICR bfset #$0100,SR bfclr #$0200,SR }; SCI0_SendChar('H'); SCI0_SendChar('e'); SCI0_SendChar('l'); SCI0_SendChar('l'); SCI0_SendChar('o'); SCI0_SendChar('!'); SCI0_SendChar(''); while(1) { } }
void SCI0_SendChar(unsigned char chr) { while(!(*((word *)(SCI0_SCISR)) & 0x8000)){} *((word *)(SCI0_SCIDR)) = chr; }
[此贴子已经被作者于2006-6-8 12:41:48编辑过] |