 
					
				
		
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
 
					
				
		
 kerryzhou
		
			kerryzhou
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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!
-----------------------------------------------------------------------------------------------------------------------
Hi Athmesh,
Possible you lost last byte when switch into rx mode.
Try insert delay 1ms.before rs485_rx_mode function.
BR.
Darius Babrauskas
 
					
				
		
Thanks
