UART TXDATA last byte missing

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

UART TXDATA last byte missing

1,170件の閲覧回数
athmesh_n
Contributor IV

Data from UART is missing last byte using the following code snippet.  

 rs485_tx_mode();                                                    //Setting as Transmission
 for(mb=0;mb<u8ModbusADUSize;mb++)               //u8ModbusADUSize = 8
 {
  while(~LPC_USART0->STAT & (1<<3)); 
  LPC_USART0->TXDATA = u8ModbusADU[mb];
 }
 while(~LPC_USART0->STAT & (1<<3)); 
 rs485_rx_mode();                                                 //Setting as Reception

u8ModbusADUsize is 8, and the u8ModbusADU[7] is missing during continuous run. But while debugging step-by-step we are getting the full output including u8ModbusADU[7]. 

Processor : LPC1517

IDE            : MCUXpresso 

Clock          :   Internal Clock

Thanks and Regards,

Athmesh Nandakumar

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

1,009件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi ATHMESH NANDAKUMAR,

     Please modify your code like this:

 rs485_tx_mode();                                                    //Setting as Transmission

 for(mb=0;mb<u8ModbusADUSize;mb++)               //u8ModbusADUSize = 8
 {
  while(~(LPC_USART0->STAT & (1<<2))); 
  LPC_USART0->TXDATA = u8ModbusADU[mb];
 }

 while(~(LPC_USART0->STAT & (1<<3))); 
 rs485_rx_mode();                                                 //Setting as Reception

If you still have problems, just add a small delay above  rs485_rx_mode();

Please try it again.

Any updated information, just let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

1,009件の閲覧回数
darius_b
Contributor I

Hi Athmesh,

Possible you lost last byte when switch into rx mode.

Try insert delay 1ms.before rs485_rx_mode function.

BR. 

Darius Babrauskas

1,009件の閲覧回数
athmesh_n
Contributor IV

Thanks

0 件の賞賛
返信