cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L496VG Using LPUART with LSE 32768 kHz with 9600 bd from Stop2 mode: No reliable evaluation of the first byte

MKret.1
Associate

I use Modbus RTU 8N1 with 9600 bd. I always have sent the same 8 byte request. The first byte of the message is 0x01.

In about 85% of all tests the STM32 evaluates the request correctly. In a 15% of all tests the first byte is evaluated as 0x80 or 0x81. The other 7 bytes are always correct.

I see the wrong byte in the LPART Rx register as soon as the LPUART interrupt comes.

I checked the message at the RX input of the MCU with the oscilloscope: Everything is fine: timing, bit lenght, byte lengtht, start bit, stop bit, every single bit of the message is correct. Even if the MCU evaluates the first byte wrong.

I gave the LPUART a little time break after wake up from stop 2 mode. That did not help. I checked the baudrate in the register. It´s fine. I tried a lot of other things that didn´t helped.

Do you have an solution idea?

1 ACCEPTED SOLUTION

Accepted Solutions
MKret.1
Associate

Hi JHOUD,

thank you for your answer and the explanation. I use 874. 873 did not help.

Meanwhile I have found my mistake: I forget to set the bit UCESM in register LPUART1->CR3. Now the LPUART works stable out of stop2 mode.

The bits LPUART1SMEN in register RCC->APB1SMENR2 and UESM in LPUART1->CR1 I had already considered before.

BR

Max

View solution in original post

2 REPLIES 2
Bubbles
ST Employee

Hi @MKret.1​,

what BRR value are you using? 873 or 874? Try the other one.

Is the issue getting worse with temperature?

The 32768 is not divisible by 9600 so the LPUART contains a mechanism to sample the bits at uneven clock cycles, sometimes after 4 clock periods, sometimes after 3. Sometimes resetting that mechanism by disabling and re-enabling the LPUART helps, but it also depends on the communication counterpart.

BR,

J

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

MKret.1
Associate

Hi JHOUD,

thank you for your answer and the explanation. I use 874. 873 did not help.

Meanwhile I have found my mistake: I forget to set the bit UCESM in register LPUART1->CR3. Now the LPUART works stable out of stop2 mode.

The bits LPUART1SMEN in register RCC->APB1SMENR2 and UESM in LPUART1->CR1 I had already considered before.

BR

Max