AnsweredAssumed Answered

Framing errors with UART1 on K64F

Question asked by dave408 on Jul 6, 2015
Latest reply on Jul 9, 2015 by dave408

I'm communicating from a K64F (master) to a K22F (slave) using Modbus RTU over RS485.  On the K64F, I am using UART1 connected to a TI SN65HVD1762 RS485 transceiver.

 

The problem I am having is that I'm seeing framing errors via my logic analyzer.  I am currently trying to send the following 8 byte packet: { 0x02, 0x04, 0x00, 0x0A, 0x00, 0x02, 0x51, 0xFA }.

 

If I use the following code:

 

     if( kStatus_UART_Success != Rs485WriteHelper( FSL_RS485_COMP, RS485_1_TXEN, packet, packet_size, MODBUS_SEND_TIMEOUT)) {       result.data.error_code = E_UART_MODBUSRTU_SEND;       return result;      }   

 

uart_status_t Rs485WriteHelper( uint32_t instance, uint32_t de_pin, const uint8_t *txBuff, uint32_t txSize, uint32_t timeout) {     GPIO_DRV_SetPinOutput( de_pin);     uart_status_t ret = UART_DRV_SendDataBlocking( instance, txBuff, txSize, timeout);     GPIO_DRV_ClearPinOutput( de_pin);     return ret; }

 

where packet_size is 8, I get a framing error in my logic analyzer results right before the 0x51, like this:

The results are the same if I send the first four bytes, followed by the next four bytes.  The results are the same if I send all 8 bytes, but one byte at a time.

 

What's weird is that If I change my code to endlessly loop and send 8 bytes at once, or 1 byte at a time, I don't get any framing errors -- see below:

 

I'm not sure what's going here.  Timing must be okay if the logic analyzer can read an endless stream of bytes.  Can anyone suggest something else for me to look at to understand why it's behaving like this?

Outcomes