hardware
SP56F801A60
software: Codewarrior 7.2
I used PE to generate a program of UART, baud rate is 9600.
it can work normally.
when I write myself, it always can't work normally. I set register as same as that program generated by PE.
this is program I wrote,
I always can't communicate with PC,
Please help me!
#include"56801.h"
typedef unsigned int word;
void SCI0_SendChar(unsigned char);
void main(void)
{
asm
{
bfset #$40,X
FIU_CNTL
bfset #$103F,X:ISOCTL
bfclr #$FFBF,X
FIU_CNTL
bfclr #$FFFB,X
LLCR
};
while(*((word *)(PLLSR)) & 0x4 ){}
asm
{
move #$81,X
LLCR
move #0,X:CLKOSR
move #$11D,X
LLDB
};
while(!(*((word *)(PLLSR)) & 0x20)){}
asm
{
move #$82,X
LLCR
bfclr #6,X:GPIO_A_PER
bfset #6,X:GPIO_A_DDR
bfclr #6,X:GPIO_A_DR
move #0,X
YS_CTRL
orc #3,X:GPIO_B_PER
move #0,X
CI0_SCICR
move #$00c3,X
CI0_SCIBR
orc #8,X
CI0_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('\n');
while(1)
{
}
}
void SCI0_SendChar(unsigned char chr)
{
while(!(*((word *)(SCI0_SCISR)) & 0x8000)){}
*((word *)(SCI0_SCIDR)) = chr;
}