cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware implementation of LIN bus using USART1 on STM32L562 MCU

gdecker1
Visitor

First time designing for ST microcontrollers, so I thank you for your patience.

 

I see by the datasheet that USART1 can be used as a LIN bus directly without a LIN bus transceiver, but I can't find any examples of how the hardware is implemented when that's set up. My assumption is that I need a 1kohm pull up to Vcc on the master and a weaker pull up on the slaves, connected to USART1_TX and leaving USART1_RX floating.

 

Is this accurate? If not, how do I use the LIN bus peripherals on the STM32L5 series?

7 REPLIES 7
AScha.3
Chief III

No.

LIN bus is typical on cars, 12V signal level.  And STM32 is 3v3 cpu - so you always need transceiver chip.

But you can use the uart, set in linbus-mode, to work with transceiver .

 

AScha3_0-1738947327299.png

 

If you feel a post has answered your question, please click "Accept as Solution".

That doesn't make sense to me. LIN bus transceivers already work with standard UARTs. There's no reason for a special LIN bus setting in the microcontroller if you already have a UART.

The datasheet for the STM32L562xx part says: 

  • These interfaces provide asynchronous communication, IrDA SIR ENDEC support, multiprocessor communication mode, single-wire half-duplex communication mode and have LIN master/slave capability.

So they have the ability to be used as a half-duplex and as LIN master/slave. The question I have is how am I supposed to connect the half-duplex connection? Do I use just the TX line, or just the RX line, or do I short them together?

The question of the level shifter is one I'll have to investigate further, but one of the reasons I chose this chip for my design was because it supported LIN without a separate transceiver.

 

"sense to me" ...come on.

see ds, maximum voltage on pins:

AScha3_0-1738951447225.png

So if your LIN bus is working under 5V , its might work ok ; but never on 12V , without level shifter or transceiver.

If you feel a post has answered your question, please click "Accept as Solution".

LIN bus doesn't have to be 12V. It's typically 12V because it's typically used in cars. I'm not developing for automotive. I have an example of the legacy system that is currently in use that uses a LINbus transceiver with BATT connected to 5V. It's functional, and has been for a while.

 

So yes, if I needed this system to operate at 12V then I would put in a level shifter, but I don't need it to run at 12V. Regardless, that doesn't answer my question. If I enable LIN mode, what pin do I connect to? RX, TX or both?

>what pin do I connect to? RX, TX or both?

RX and TX to the rx tx pins of the LIN transceiver...

just try in Cube: set the uart to LIN-mode and see, what it changes on rx + tx hardware. (nothing.)

read in rm :

AScha3_0-1738953885146.png

So you get LIN break detection etc , but there is no LIN transceiver built in the cpu.

If you insist on working without transceiver, maybe you could try: set tx pin to alternate open drain with pullup on, connect tx to rx and see, if its working. Maybe discrete pullup resistor to add. (internal has about 40 k .)

But be aware : if using internal pullups or output, your limited to 3v3 max. level !

"5V tolerant is only for inputs " !  So will need transceiver on 5V-LIN also.

Just connect it to the transceiver, as you did it on your system up to now.

If you feel a post has answered your question, please click "Accept as Solution".

Ok.

I was hoping to reduce component count but if LIN Mode doesn't mean I can use the port as a half duplex bus then I guess I'm stuck with it.

See what i wrote...you can use it half duplex - but only at 3v3 max. level.

see rm, half duplex mode...

AScha3_0-1738955753846.png

 

If you feel a post has answered your question, please click "Accept as Solution".