2019-04-05 09:35 AM
I'm still very new to STM32 processors, and using CubeMX to generate my basic code structure (for TrueStudio). In the code below, if I uncomment code section A, the yellow LED blinks, but not evenly...
What am I missing here?
Now, if I comment out section A, so that section B runs, the red LED comes on, but then the code hangs at the HAL_Delay(1000) so the yellow LED never comes on. If I drop that to HAL_Delay(100), the red LED comes on again, but the yellow LED blinks at approx 2.5Hz. There are no other timers or interrupts running.
I don't know what to check next. If this is somehow expected behaviour, which doc explains how this is supposed to work?
Thanks
/* USER CODE BEGIN 2 */
// HAL_TIM_Base_Start_IT(&htim17);
// Code section A...
while (1)
{
HAL_GPIO_TogglePin(IENC1_GPIO_Port, IENC1_Pin); // Toggle yellow LED
HAL_Delay(500);
}
// Code section B...
HAL_GPIO_WritePin(IENC0_GPIO_Port, IENC0_Pin, GPIO_PIN_SET); // Red LED on
HAL_Delay(1000);
HAL_GPIO_WritePin(IENC1_GPIO_Port, IENC1_Pin, GPIO_PIN_SET); // Yellow LED on
while(1);
...
2019-04-05 09:55 AM
HAL_Delay typically depends on the SysTick interrupt, that it fires and is configured correctly. Usually via HAL_Init()
I'd suspect the tool chain or generated code.
Review what else is on the pin.
2019-04-05 10:10 AM
If you use HAL_Delay inside an interrupt routine, havok behaviour may be seen. Check your ISRs and callbacks if any outside the shared code extract.
2019-04-05 10:11 AM
Thanks Clive. I completely re-created the project in CubeMX in a new directory, with a new name. All I have set is SWD enabled and 2 outputs for the LEDs. And I set the FCLK to 48MHz. Image below shows what I have. That's all. No other timers or peripherals enabled. Same exact behaviour.
I'm going to see if I can download an older version of CubeF0 to see if that makes a difference.
2019-04-05 10:12 AM
I have no interrupts set. See my response below to Clive about my configuration.
Thanks.