2023-06-30 04:22 AM - edited 2023-06-30 04:45 AM
Hi everyone,
Do you think there is any reason why a set of instructions (20 lines max.), including UART transmission, works fine within the while(1) block but it doesn't work if that exact set of instruction is in a function, within the same while(1) block? In practice it seems to transmit correctly unless the instructions are in a separate function. I am running out of ideas.
If necessary, I will be happy to provide more details.
Thank you!
Edit: when I say that I doesn't transmit correctly, I mean that only 2 out of 6 packets are sent. When the instructions are not in the function and directly in the while block all the packets are send correctly.
Solved! Go to Solution.
2023-06-30 08:16 AM
Among possible reasons: very marginal timing. A function call takes few more instructions. A problem with stack: is it located in some unfortunate place? And so on. In this business, every bit of difference matters.
2023-06-30 05:03 AM
Hello, this is not something that anybody would be expecting, from your description it doesn't sound like any error that happens to lot of users.
You may need to provide more details. When you debug the code, do the HAL actually manipulate the UART registers? Are there any error flags in the UART status register?
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-06-30 05:10 AM - edited 2023-06-30 05:13 AM
Dear J,
thank you for your reply. Please tell me which kind of detail can help you understanding the problem.
To your questions, yes the HAL manipulate the UART registers and I do not see any error in the status register :(.
The thing that is even weirder is that the code was actually working fine and then suddenly it stopped working. Can be that something broke in the MCU, or that I unintentionally changed any setting in the .ioc file?
2023-06-30 05:36 AM
Hi, the ioc file doesn't matter unless you regenerate the project from the CubeMX again. And the ioc file only initializes the peripheral, so if something is wrong with that, you'd see no communication at all.
Probably best if you attach the ioc file and the source code you modified so we can take a look.
Are you using Nucleo, or your own board?
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-06-30 06:05 AM
Details:
Show the code that works and show the code that does not work.
2023-06-30 08:16 AM
Among possible reasons: very marginal timing. A function call takes few more instructions. A problem with stack: is it located in some unfortunate place? And so on. In this business, every bit of difference matters.