cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 LIN usage

Fabrizio Pizzolato
Associate II
Posted on September 14, 2017 at 13:57

Hi all, I have a problema using STM32F429 USART Hal functions in conjunction with a LIN device, using USART1.

I configure the peripheral as any other UART in the project, using a pattern like:

LinPinInit()

{

   ...

}

LinEnable(LIN_ENABLE)

{

   ...

}

LinUartInit(9600)

{

   ...

   HAL_LIN_Init(&LinUart, UART_LINBREAKDETECTLENGTH_10B);

   HAL_NVIC_SetPriority(LIN_UART_IRQ, 5, 0);   

   HAL_NVIC_EnableIRQ(LIN_UART_IRQ);

}

Then I try to send a message to a sensor and receive some byte in answer.

I send starting with 

HAL_LIN_SendBreak(...);

then HAL_UART_Transmit to send 0x55 and sensor identifier field. 

I verified with an oscilloscope that some byte are indeed exchaged on the physical lines doing so, TX line of the microcontroller show this.  But:

1. in case I execute a polling read using HAL_UART_Receive, I got 9 bytes with a wrong crc16.

2. In case I use HAL_UART_Receive_IT (calling the function before the syncronous transmit of course) I got a frame error. 

I don't understand what is wrong with my configuration. Any guesses? thanks.
1 REPLY 1
Fabrizio Pizzolato
Associate II
Posted on September 15, 2017 at 15:02

I see 0 views on this one so I think there was some issue also with the forum.

No problem, I was able to solve by myself and I will share the solution: with the mentioned device and I assume with all LIN transceivers, LIN line is always connected to the MCU's RX line; this results in always receiveing what you send, including the LIN break message. For my application the solution was to disable the receiver on the USART bus (actually initiating it in TX mode only) then to activate it (initializing again the line in TX_RX) when data was to be received. This solved the issue.

Have a nice day.