Skip to main content
SProg
Associate III
December 14, 2019
Question

Free-RTOS on STM32L151C6 using STM32CubeMX [Timing issue]

  • December 14, 2019
  • 1 reply
  • 544 views

Hello,

i am making a simple project for STM32L151C6 using Cube. I am using as timing source the TIM2 and i just use the below code to toggle a LED:

/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void const * argument)
{
 /* init code for USB_DEVICE */
 MX_USB_DEVICE_Init();
 
 /* USER CODE BEGIN 5 */
 /* Infinite loop */
 for(;;)
 {
 HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); //Toggle the state of pin 
 osDelay(50);
 }
 /* USER CODE END 5 */ 
}

The problem is that HAL_GPIO_TogglePin() is executed not every 50 mSec but every 6-7 seconds.

Is there something is missed out during configuration? I am attaching the Cube file.

This topic has been closed for replies.

1 reply

SProg
SProgAuthor
Associate III
December 15, 2019

Seems like MX_USB_DEVICE_Init(); is somehow (maybe due to interrupts priority) affecting the timings.

When i comment this line, LED blink period is correct.