sundar dev

mc9s12dp256 - Problem with transmitting out a stream of bytes through SCI..

Discussion created by sundar dev on Feb 29, 2008
Latest reply on Mar 5, 2008 by MIKE YETSKO


Firstly, let me explain what I'm trying to do.
I'm using mc9s12dp256.

The idea is to

->transmit a stream of bytes from one mcirocontroller
to another(say from muc1 to muc2) thru SPI- this part works fine.

->next the received stream of bytes in muc2 are to be
sent out on the SCI to the hyperterminal on the comp
thru RS232.

Everything is being done using interrupts.
Now, at the receiver end(i.e.muc2) the Interrupt Service
Routine for both SPI reception and subsequent SCI transmission has been written.

The sequence of events that occur( as I've understood them)are as below- if I'm wrong, please correct me
1. muc1 transmits 1st byte. At the receiver end, since
SPTIE interrupt is enabled, on receiving the byte, an interrupt will be raised, followed by copying the byte in to an array.
2. mean while, in SCI, since TIE and TCIE bits are set, the corresponding interrupts are enabled, and for the 1st
byte since TDRE and TC flags are set, an interrupt is raised and the byte must be sent out.

But, here's where a potential timing problem arises. If the SPI is programmed to receive data @ a rate slower than the SCI can transmit, then the SCI will end up skipping a few bytes.

To overcome this, what we did was, we equated the time taken for SPI to receive 8 "bits" with the time taken for the SCI to transmit 10 "bits"( 8 data+ 1 start+ 1 stop) and found out the value to be loaded into SCIBDL. Is this how it is done? What other method can be used to transmit data out from SCI with out timing data errors occuring in the program that I've described above?



Added p/n to subject.

Message Edited by NLFSJ on 2008-02-29 09:15 AM