USART-UART problem with STM32F446

For general Flowcode discussion that does not belong in the other sections.
Post Reply
max.tisc
Posts: 103
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 8 times

Flowcode v9 USART-UART problem with STM32F446

Post by max.tisc »

hi everyone, i think there are some problems with the UART and USART serials on the STM32f446, to do some tests i used a Nextion display with UART communication connected to channel 1 USART1, the test consists only of changing a page on the display and repeating on a UART output the bits sent by the display and reading them on the PC via a normal USB TTL converter. in the screenshot N1 you can see the data sent by NEXTION, and they are correct, in the screenshot N2 you can see the data sent by the UART channel 4 UART4 and they are not correct, consequently as you can see in the screenshot 3 the data read on the PC do not make sense and of course the page on the display does not change. at first I thought that the USART and UART ports were not fully compatible so I moved the display to the UART5 channel port but nothing changed
I would like to point out that I have been using these displays for quite some time and connected to an atmega2560 I have never had these problems, while I have been testing the STM32 for a short time
I also attach the file sorry if it is rough
Please help me
thanks
Attachments
screeshot.zip
(78.93 KiB) Downloaded 18 times
TEST_2_NEXTION_F446 (2).zip
(3.42 KiB) Downloaded 15 times

LeighM
Valued Contributor
Posts: 441
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 81 times
Been thanked: 242 times

Re: USART-UART problem with STM32F446

Post by LeighM »

Hi,
First thing to note is that your UART RX interrupt code (RX_232) has far too much processing.
The UART RX interrupt code should be as short as possible, and certainly not wait for more received characters.
e.g. you should only receive one character, store it in a buffer (for later processing), then exit.
Or perhaps have a "state" value that is changed by the value received.
Then use the "state" in the main macro to decide what further action to take, such as displaying data.
Hope that helps.

max.tisc
Posts: 103
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 8 times

Flowcode v9 Re: USART-UART problem with STM32F446

Post by max.tisc »

ok LeighM thanks, I did as you suggested and now it works
thanks a lot
Attachments
Screenshot 2025-01-24 220554.png
Screenshot 2025-01-24 220554.png (67.61 KiB) Viewed 2086 times

max.tisc
Posts: 103
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 8 times

Re: USART-UART problem with STM32F446

Post by max.tisc »

Hi, I still have some problems with data reception, as you can see from the screenshot to check if the data is stored correctly in the buffer I send them to an external serial port, by pressing the button on the display for the first time I receive the data circled in red and they are not correct, by pressing the second time I record them correctly in the buffer circled in blue and in fact then you can see that the request to change page is sent to the display, by analyzing the data flow coming out of the display the data is always correct
thank's
Attachments
STM32F446_NEXTION+UART+OROLOGIO.fcfx
(29.73 KiB) Downloaded 7 times
Screenshot 2025-02-03.png
Screenshot 2025-02-03.png (129.14 KiB) Viewed 1738 times

LeighM
Valued Contributor
Posts: 441
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 81 times
Been thanked: 242 times

Re: USART-UART problem with STM32F446

Post by LeighM »

Note for Matrix: I think there is a chance that this issue is connected with the fixes done to the F4 series FCDs in v10,
could these be ported back to v9?

edit: Ah, just spotted something in your code, you are setting a flag on any received character, which then causes processing in the main.
So you could be processing before the whole packet has been received.
I haven't had time to look at the protocol, but you might be better setting the flag_232 when you have determined that you have received a complete data packet.

max.tisc
Posts: 103
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 8 times

Re: USART-UART problem with STM32F446

Post by max.tisc »

ok thanks, your advice is always useful, I eliminated the flag_232, now I modified the code (part in yellow) checking that the 7 bytes have arrived, (I hope I did it right), on the test code it works at every shot, but when I go to bring it back to the more complex code it doesn't work correctly and I have to press the button several times to make it take the correct sequence in red the incorrect ones in blue the correct one, even if the last byte is wrong and the display changes screen because I only check the value of the first 3
could it be the problem of the correction you wrote about?
thanks
Attachments
Screenshot 2025-02-03 .png
Screenshot 2025-02-03 .png (73.97 KiB) Viewed 1687 times
STM32F446_NEXTION+UART+OROLOGIO.fcfx
(30.42 KiB) Downloaded 9 times

Post Reply