Hi, I'm trying everything to get this project to work, but can't. I have tried moving library files and having tons of problems with Keil's linker, but I somehow (idk how atm) managed to compile everything smoothly. I'm trying to use the UART module of the STM32F401RET board to calibrate the limiting distance the sensor should set the alarm on. The sensor is working just fine with the example ST provided. I used the STM32CubeMX to make a UART example code for initialization, and followed a tutorial to make it work (it worked by itself) the thing is that when I try to merge them together (the sensor's code and the UART example) the UART transmision timeouts, and never sends anything through the UART module.
Anyone has any advice about this? I really need your help! Thank you for your time, Alan.
The standard rule when merging code from different sources is to make sure you know how the code works.
If the sensor code locks up while waiting for something, then that will affect other code that assumes some state variable or hardware should be regularly polled.
Sometimes a solution might be to use an RTOS so you run the two functionalities in different threads to make sure the OS gives time slices to both functionalities as needed. But that still requires you - the developer - to understand the code good enough to be able to make use of the primitives available in the RTOS in regards to waiting for events etc.
Use the debugger to see where it's falling over,
Maybe output some diagnostic trace messages to a spare UART to see what's happening.
Compare & contrast for your 2 working samples and the combined code ...
I've used the debugger, and that's how I know that the combined code is doing a timeout. It's weird because after debugging and comparing step by step, both of them start the same, but the merged one takes a different path after one cycle of the while loop waiting for the data to be sent. Since there isn't like an error or something, I really don't know where to go from here, since it just timeouts, and continues with the code.
Thanks!
output some diagnostic trace messages to a spare UART to see what's happening - both in the separate cases, and the combined code.
I just solved it, saw a post on another forum about a guy who had a somewhat similar problem that made me think on the libraries, and saw that 3 files weren't updated. I replaced them and it worked! For future reference, if someone stumbles upon this problem, the files were the following: stm32f4xx_it.c stm32f4xx_hal_msp.c system_stm32f4xx.c with their corresponding header files.
Thank you guys for the help!