Serial communications Approach

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Serial communications Approach

ソリューションへジャンプ
1,340件の閲覧回数
karthick1987
Contributor II

 

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).

       
       while(SCI1S1_TC == 1)
       {
       }

 

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

ラベル(1)
0 件の賞賛
返信
1 解決策
810件の閲覧回数
peg
Senior Contributor IV

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.

 

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
811件の閲覧回数
peg
Senior Contributor IV

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.

 

0 件の賞賛
返信
810件の閲覧回数
karthick1987
Contributor II

Got it Peg

 

Thanks a lot mate. Its working now!

 

Cheers

Karthick

0 件の賞賛
返信