UART showing framing error while receiving response from stn2100 OBD tranceiver unit to MPC5748G

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART showing framing error while receiving response from stn2100 OBD tranceiver unit to MPC5748G

4,121 Views
priya_p
Contributor IV

UART is configured to establish communication between STN2100 OBD transceiver and MPC5748G Microcontroller. For every AT commands given by microcontroller via uart, stn2100 should give a response. But after the first reception of response, uart status is showing framing error and in the received buffer, junk data is stored. Please help to solve this issue.

INST_LINFLEXD_UART2: MPC5748G microcontroler ===========uart=================PC

INST_LINFLEXD_UART3: MPC5748G microcontroler ===========uart=================STN2100 OBD

for( ;; )
{

// ATI_command is defined as "ATPPS\r\n" : to print all configurable parameters in stn2100 as response


LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART3, (uint8_t *)ATI_Command, strlen(ATI_Command), TIMEOUT);


LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART2, (uint8_t *)ATI_Command, strlen(ATI_Command), 300);
}


/* Receive and store data byte by byte until new line character is received,
* or the OBD_Rxbuffer becomes full (256 characters received)
*/LINFLEXD_UART_DRV_ReceiveData(INST_LINFLEXD_UART3, OBD_Rxbuffer, 1U);


/* Wait for transfer to be completed */
while(LINFLEXD_UART_DRV_GetReceiveStatus(INST_LINFLEXD_UART3, &bytesRemaining) == STATUS_BUSY);

/* Check the status */
status = LINFLEXD_UART_DRV_GetReceiveStatus(INST_LINFLEXD_UART3, &bytesRemaining);


if (status != STATUS_SUCCESS)
{
/* If an error occurred, send the error message and exit the loop */
LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART2, (uint8_t *)errorMsg, strlen(errorMsg), 300);
break;
}

//sending to pc hyper terminal
LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART2, (uint8_t *)OBD_Rxbuffer, strlen(OBD_Rxbuffer), 300);


/* Reset the OBD_Rxbuffer index to start a new reception */
OBD_RxbufferIdx = 0U;
}

0 Kudos
Reply
12 Replies

4,005 Views
priya_p
Contributor IV

I have a query. why this frame error happens after receiving all the byte of current uart frame. If obd is transmitting 10 bytes of data as a response to one command send from MCU to OBD, then up to 10 bytes it receives properly at the MCU side. Once it receives 10 bytes, obd sends OBD sends '>' ( "ready for next transmission") symbol, then it is entering in to uart frame error. why it is so?

         If it is some configuration error, while receiving the 1st byte itself it should enter framing error, because each byte have its own start and stop bit. framing error means it fails to detect a stop bit. So if the data is of 10 byte, then it successfully detects 10 stops bits and fails in the 11th byte i.e. after '>' symbol transmission from OBD to MCU. Please help me to clarify this doubt.

--------1st round----------------

MCU TO OBD

ATI :: send the identification version

OBD TO MCU

eijver3.124\r>

---------2nd round--------------

MCU TO OBD

ATPPS ::

OBD to MCU:

": status: uart framing error // junk data in receiver buffer

0 Kudos
Reply

3,993 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

if the data format stays the same and receiver is enabled, then frame error should not be detected for received character, I think.
If receiver is disabled, which is done after defined number of chars is received, then LPUART_DRV_ReceiveData must be called again prior new char is going to be received.

BR, Petr

0 Kudos
Reply

3,964 Views
priya_p
Contributor IV

After the end of every reception I am calling LPUART_DRV_ReceiveData() function. Still its giving UART Frame error from second transmission onwards.

1st iteration

ATI

VERSION3.1

status: SUCCESS

>

2nd iteration

ATPPS

#"~;

status: UART FRAMING ERROR

_______Command from MCU to STN2100

_______Response from STN2100 Obd Transceiver

 

 

for( ;; )
{

LINFLEXD_UART_DRV_ReceiveData(INST_LINFLEXD_UART3, OBD_Rxbuffer, 1U);

 

LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART3, (uint8_t *)ATI_Command, strlen(ATI_Command), TIMEOUT);

 

while(LINFLEXD_UART_DRV_GetReceiveStatus(INST_LINFLEXD_UART3, &bytesRemaining) == STATUS_BUSY);


status = LINFLEXD_UART_DRV_GetReceiveStatus(INST_LINFLEXD_UART3, &bytesRemaining);


if (status != STATUS_SUCCESS)
{
break;
}

OBD_RxbufferIdx = 0U;

}

___

0 Kudos
Reply

3,826 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

not sure why this happens.
Do you really see expected signals on UART lines? Still you did not share those.
Check also returned value of driver functions. Finally how does your RX callback looks like?

BR, Petr

0 Kudos
Reply

3,777 Views
priya_p
Contributor IV

Thank you for all replies. It got resolved.

0 Kudos
Reply

4,101 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

try to call ReceiveData before sending command.

BR, Petr

0 Kudos
Reply

4,072 Views
priya_p
Contributor IV

If i am not sending the command, no reply will be there. It's like a request-response type protocol. So, only if i am transmitting a command, then only stn2100 will give a response. 

0 Kudos
Reply

4,061 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

receiveData is just preparing driver for reception, so in your case should be called prior to sending data, i think.

BR, Petr

0 Kudos
Reply

4,053 Views
priya_p
Contributor IV

still it is giving UART framing error. 

0 Kudos
Reply

4,040 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

please provide UART signals measurement, using analyzer or scope, and relevant used code.

BR, Petr 

0 Kudos
Reply

4,006 Views
priya_p
Contributor IV

I will send the requested details asap. I have a query. why this frame error happens after receiving all the byte of current uart frame. If obd is transmitting 10 bytes of data as a response to one command send from MCU to OBD, then up to 10 bytes it receives properly at the MCU side. Once it receives 10 bytes, obd sends OBD sends '>' ( "ready for next transmission") symbol, then it is entering in to uart frame error. why it is so?

         If it is some configuration error, while receiving the 1st byte itself it should enter framing error, because each byte have its own start and stop bit. framing error means it fails to detect a stop bit. So if the data is of 10 byte, then it successfully detects 10 stops bits and fails in the 11th byte i.e. after '>' symbol transmission from OBD to MCU. Please help me to clarify this doubt.

--------1st round----------------

MCU TO OBD

ATI :: send the identification version

OBD TO MCU

eijver3.124\r>

---------2nd round--------------

MCU TO OBD

ATPPS ::

OBD to MCU:

": status: uart framing error // junk data in receiver buffer

 

0 Kudos
Reply

4,057 Views
priya_p
Contributor IV

Ok I got it. I will try that way then. Thanks.

0 Kudos
Reply