Ji junli

baud rate set

Discussion created by Ji junli on Jun 8, 2006
Latest reply on Jun 13, 2006 by Niklas Forsgren
hardware:smileyvery-happy: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:smileyvery-happy:FIU_CNTL
   bfset             #$103F,X:ISOCTL
   bfclr             #$FFBF,X:smileyvery-happy:FIU_CNTL
   bfclr             #$FFFB,X:smileytongue:LLCR
 };
 
 while(*((word *)(PLLSR)) & 0x4 ){}
 
 asm
 { 
      move              #$81,X:smileytongue:LLCR
      move              #0,X:CLKOSR
      move              #$11D,X:smileytongue:LLDB
    };
 
 while(!(*((word *)(PLLSR)) & 0x20)){}
 
 asm
 {
   move              #$82,X:smileytongue:LLCR
 
      bfclr             #6,X:GPIO_A_PER
      bfset             #6,X:GPIO_A_DDR
      bfclr             #6,X:GPIO_A_DR
   
      move              #0,X:smileyfrustrated:YS_CTRL
      orc               #3,X:GPIO_B_PER
      move              #0,X:smileyfrustrated:CI0_SCICR
      move              #$00c3,X:smileyfrustrated:CI0_SCIBR
      orc               #8,X:smileyfrustrated: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;
}
 

Outcomes