2025-01-10 03:18 PM
Hello all, I am currently working with the STM32CubeIDE. I wrote a program that didn't end up working but concluded the code was fine after reviewing it. I tried copy and pasting the code into a different project within the IDE, and it works just fine. Does anyone know why this might be?
The code does not work when pasted into existing projects, or new projects, except for the one particular existing project. There are no error codes thrown when it doesn't work; it builds and downloads to the board just fine but then doesn't run.
The program is attached.
2025-01-10 04:51 PM
It is a perfect puzzle : ) Not possible to tell is you code fine or not. It may be fine under certain conditions and not fine under other conditions - so called 'contract'. Consider that even a broken watch shows the correct time twice in a day. Debugger is your friend.
2025-01-11 01:49 AM
@dj-b wrote:The code does not work when pasted into existing projects, or new projects, except for the one particular existing project.
Sounds like it depends on something that is in that one particular project, and missing from all the others.
You're going to have to do some debugging to investigate what's going on.
Debugging is a key skill in development: You need to get beyond just throwing your hands up and saying, "it doesn't work" - that tells nothing.
Think about:
As you have a case where it works, and others where it doesn't, Carefully compare & contrast what happens in the working case to what happens in the non-working cases.
Some debugging tips: