HAL_Delay not affecting frequency of a Blinking Light
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-28 12:05 PM
I am new to STM32, and I am using a STM32L152c discovery board to run a sample blinking light program. I am using HAL_Delay to control the frequency of the blinking light. However, the frequency does not change when I change the argument to HAL_Delay, or even if I remove HAL_Delay altogether. I would appreciate any assistance. I have included the main function and the HAL_Delay code that was provided in the project setup.
Also, where can I find code documentation? I was trying to find something to help explain HAL_Delay and other functions, but I could not find anything.
int main(void){
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_ADC_Init();
MX_LCD_Init();
MX_TS_Init();
while (1){
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
HAL_Delay(1000);
}
}
//This function was sourced from the stm32l1xx_hal.c file generated at project start
__weak void HAL_Delay(uint32_t Delay){
uint32_t tickstart = HAL_GetTick();
uint32_t wait = Delay;
/* Add a period to guaranty minimum wait */
if (wait < HAL_MAX_DELAY)
{
wait += (uint32_t)(uwTickFreq);
}
while((HAL_GetTick() - tickstart) < wait)
{
}
}
- Labels:
-
STM32L1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-02 11:44 PM
Hi @Splatt​ ,
To generate code, you need to click on Project > Generate Code.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-25 2:46 PM
None of the above methods have worked for some reason. I ended up trying to load the example blink program for the stm32l152c board, and it worked if I did it a very specific way:
- Create a new STM32 project for my board (Default ioc setup)
- Replace the Src and Inc folders with the folders from the example
- Occasionally, a file would need to be added that was not included. For instance, the stm32l152c_discovery.h and .c files were missing, so I got those from GitHub. Would this indicate an incorrect ioc setup?
This way works to load up sample projects, but it ultimately does not answer the question this discussion is about. A second question I would ask is: is there a better way to load a sample program into STM32cubeIDE? I tried converting from one of the included toolchains (SW4STM32), but this resulted in files missing.

- « Previous
-
- 1
- 2
- Next »