2024-02-01 06:51 PM
Hello! I’m using Keil uVision to program the stm32f103c8t6 (blue pill). I’m having problems with the loops when trying to turn on and off the LED on pin 13 port C. I just wanted to use a loop to generate a delay without needing to use timers, since I wanted to generate a simple program. But when I download it to the board, the LED stays on instead of turning on and off, regardless of the wait value I put in. I would appreciate it if you could tell me if I’m doing something wrong and indicate the solution. Thanks in advance. The code is as follows:
Solved! Go to Solution.
2024-02-01 08:18 PM - edited 2024-02-01 08:19 PM
You're missing some semicolons in your code. It won't even compile.
Change "int i" to "volatile int i" so the compiler doesn't optimize it out.
Probably also want to set i back to 0 before each loop. After the first loop, all of the other loops will immediately exit.
Can always step through the code and verify registers are changed appropriately. I guess not on the blue pill. There are better boards for development.
2024-02-01 08:18 PM - edited 2024-02-01 08:19 PM
You're missing some semicolons in your code. It won't even compile.
Change "int i" to "volatile int i" so the compiler doesn't optimize it out.
Probably also want to set i back to 0 before each loop. After the first loop, all of the other loops will immediately exit.
Can always step through the code and verify registers are changed appropriately. I guess not on the blue pill. There are better boards for development.
2024-02-01 08:29 PM
Oh! Thank you for the response, it was helpful. In the post, I omitted the semicolons and the resets of the variable, but in the original code, I had them. In general, it was solved by making the variable volatile. Seriously, thank you very much for the quick response.