Hi,
I recently started with an STM32F103C8T6 on a bluepill board. I am using
SW4STM32 on Windows 10.
When writing a program that blinks an LED on PC13 with the standard
peripheral library and implementing my own SysTick_Handler and Delay
functions, the LED blinks in the correct intervals.
This is the relevant code:
1 | // Main without GPIO Initialization and APB2ENR code
|
2 | int main(void)
|
3 | {
|
4 | SystemInit();
|
5 | SysTick_Config(SystemCoreClock / 1000);
|
6 | }
|
7 |
|
8 | // My own SysTick_Handler
|
9 | void SysTick_Handler(void) {
|
10 | static uint32_t millis = 0;
|
11 | millis++;
|
12 | if (millis % 1000 == 0) {
|
13 | flipPin();
|
14 | }
|
15 | }
|
When I tried porting this code to a project using the Cube HAL libraries
provided by SW4STM32 and using HAL_Delay for delay, the LED blinks ~18x
slower. I tried following other guides on writing HAL applications,
however I could not find any examples about clock configuration.
The relevant HAL code:
1 | // Main without GPIO Initialization and APB2ENR code
|
2 | int main(void) {
|
3 | HAL_Init();
|
4 | SysTick_Config(SystemCoreClock / 1000);
|
5 | ...
|
6 | for (;;) {
|
7 | HAL_Delay(1000);
|
8 | flipPin();
|
9 | }
|
10 | }
|
While the STD code blinks the LED in precise 1000ms intervals, the HAL
code takes ~18000ms for each loop. I have looked at the HAL_Init code,
switched HAL_Init and SysTick_Config and tested flipPin, but could not
find any hints to what might cause this behaviour.
In case anybody knows what I am doing wrong, please let me know. Thank
you