I am also facing the same problem. I am able to Transmit Data but unable to receive data. I tried setting SCGC1 = 0x03 but still it is getting stuck in the receive portion. Snippet of the code:
SCI1BDH = 0;
SCI1BDL = 156;// Set baud rate to 4800 (SCI1BDLSTR = 12M/(4600x16)
SCI1C1_LOOPS = 1;// Loopback TX - RX internally for testing
SCI1C2_TE = 1; // Transmit enable
SCI1C2_RE = 1; // Rx enable
SCI1D = 'A';
// Wait for transmission complete
while(!SCI1S1_TDRE)
{ }
LEDScroll("T");
while(!SCI1S1_RDRF)
{
}
//Never comes to this portion of the code
LEDScroll("R);
I'm not sure what problem is the same, but your pseudocode is wrong. To send data you have to read status register with TDRE bit set, and only then write to the data register. In case last read of status register returned TDRE==0, write to data register shouldn't do anything. It should be in this order, not reversed:
while(!SCI1S1_TDRE)
{ }
SCI1D = 'A';