I had to fiddle around with the SCI a bit and wanted to know something.
This is what my serial code looks like (I am not using interrupts here).
SCI1D = i;
while(SCI1S1_TC == 1)
{ }
and in the main for loop i have
for( ; ; )
{
LCD_write('y');
LCD_write('o');
/* __RESET_WATCHDOG(); by default, COP is disabled with device init. When enabling, also reset the watchdog. */
} /* loop forever */
LCD_write() is the function that contains the first piece of code.
Now I did notice on the LCD screen that it displayed a series of y's followed by a series of o's ! as opposed to series of yo's continuously !
This has led me to think that I am using the wrong approach to serial communication here. So please tell me if i am actually missing something out ? like the transmit buffer or something of that sort. Also I wanted to know what your approach to this would be like?
Please advice.
Cheers
Karthick
Solved! Go to Solution.
Hello Karthick,
Your test here is wrong. The TC bit is set when the whole byte has been shifted out of the shift register. It is reset by reading it then writing to the SCID (amongst other more complicated things).
Normally you would test the TDRE bit for 1 before you write to SCID. With RS-232 you don't really care when the byte is completely shifted out.
It is normally used with, say, half duplex two-wire RS-485 where you need to know this to turn of the transmitter so you can recieve again. It is only tested after the last byte in a string of data has been written. The TDRE test above is still done between every byte of the string.
Hello Karthick,
Your test here is wrong. The TC bit is set when the whole byte has been shifted out of the shift register. It is reset by reading it then writing to the SCID (amongst other more complicated things).
Normally you would test the TDRE bit for 1 before you write to SCID. With RS-232 you don't really care when the byte is completely shifted out.
It is normally used with, say, half duplex two-wire RS-485 where you need to know this to turn of the transmitter so you can recieve again. It is only tested after the last byte in a string of data has been written. The TDRE test above is still done between every byte of the string.
Got it Peg
Thanks a lot mate. Its working now!
Cheers
Karthick