Newbie SCI1 question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Newbie SCI1 question

1,391 Views
RoboMan
Contributor I
HI all.  I'm new to using the HCS12 for serial applications.  I just started using Codewarrior last week so bear with me.  I'm trying to set it up so it receives information from my GPS and displays it on the LCD.  I can hook my GPS up to my computer with a baud rate of 4800 and i can read it through hyperterminal.  All I want to do at this point is trip the SCI1SR1 register so it is equal to 0x02.  When I hook it up to my HCS12 board it doesn't receive anything, and the SCI1SR1 register is 0xC0 when I look at the memory.  I have it hooked up to my SC1 port on my evaluation board (the Dragon 12).   I've been looking in the SCI1SR1 for the RDRF flag to trip.  It doesn't.  Here is my code.  Any help would be great.
 
#define RDRF 0x20   // Receive Data Register Full Bit
#define TDRE 0x80   // Transmit Data Register Empty Bit
 
void SCI1_Init(void) {
 
 
 SCI1BDH=1;  //9600 Baud rate
 SCI1BDL=56;
 
   
 SCI1CR1 = 0;
/*
   7   0    LOOPS
   6   0    WOMS
   5   0    RSRC
   4   0    M
   3   0    WAKE
   2   0    ILT
   1   0    PE
   0   0    PT */
 SCI1CR2 = 0x0C;
/*
   7   0    TIE,
   6   0    TCIE
   5   0    RIE
   4   0    ILIE
   3   1    TE
   2   1    RE
   1   0    RWU
   0   0    SBK */
}
   
char InChar(void) {
 while((RDRF & SCI1SR1)== 0){};  //It gets caught HERE and loops infinitely       
 return(SCI1DRL);
}
       
void InString(char *string, unsigned short max) { 
int length=0;
char character;
 char character1;
 character = InChar();
 
   while(length<max){
     *string++=character;
     length++;
    
   character = InChar();
   }
   
 
writeLine(string, 1);//Writes to LCD
}
Labels (1)
0 Kudos
3 Replies

416 Views
RoboMan
Contributor I
Yeah thats a mistake.  Its for the correct baud rate.  I had changed the baud rate a couple times, but forgot to change the comment.
 
Josh
0 Kudos

416 Views
Lundin
Senior Contributor IV
Just be aware of the odd way Freescale clears the flags in SCI and SPI. They are cleared by reading the flag register, followed by reading the data register. So if you look at those flags in a debugger memory map, the debugger is likely clearing the flags for you and the program will hang. Try it without the debugger and check if it works (set a led or something when you receive a letter).
0 Kudos

416 Views
bigmac
Specialist III
Hello,
 
You say that you need to set hyperterminal for a baud rate of 4800 to communicate with the GPS receiver.  However, you appear to be setting your SCI code for 9600 bits per second.
 
Have you also checked your RS232 to logic level conversion?  Can you actually observe the presence of data, using an oscilloscope, at the Rx pin?
 
Regards,
Mac
 

Message Edited by bigmac on 2006-10-3012:05 PM

0 Kudos