2023-01-31 01:18 PM
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?
Solved! Go to Solution.
2023-02-03 06:08 AM
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
2023-02-01 02:18 AM
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.
2023-02-03 06:08 AM
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