2024-08-22 10:34 AM
recently i been making a device that fulfill the following requirement using stm32f103c8:
1. Use the STM32F103C8T6 (Blue Pill) development board.
2. Connect to an RGB LED using suitable I/O pins. An RGB LED is a combination of 3 LEDs (red, green,
and blue) in one package. You can produce other colours by combining these three colours.
3. Display the following colour sequence continuously: Red, Yellow, Green, Cyan, Blue and Magenta.
4. Each colour should stay on for TWO (2) seconds.
5. Add a switch, SW1. Press SW1 to immediately change the RGB LED colour sequence to flashing white at
2 Hz. White is produced by turning on all 3 LEDs (red, green, and blue) at the same time. Release SW1 to
immediately resume the interrupted colour sequence.
6. Add a second switch, SW2. Press SW2 to immediately speed up colour sequence and flashing white
operations by a factor of TEN (10) i.e. each colour should stay on for 0.2 seconds (for colour sequence),
and flashing white at 20 Hz. Release SW2 to immediately return to the default speed of colour sequence
and flashing white operations.
the program is written using c language in microvision 4. however, my code keep on getting stuck in the delay function, is there any way to solve it?
2024-08-22 11:47 AM
This is the most bizarre delay function. Almost seems artificially complicated.
void Delay(float time_del){
float factor = time_del/0.025;
for(i = loop; i < factor; i++){
if(External_F){
break;
}
SysTick_Config(0.025*SystemCoreClock);
__WFI();
}
External_F = 0;
}
Both i and loop are global variables, floats at that. Why exactly? The STM32F1 doesn't have an FPU, floats are not handled natively.
2024-08-22 04:52 PM
Please teach me how to rewrite the delay, I am very confused. I put it global cause im also using it in the other function.