cancel
Showing results for 
Search instead for 
Did you mean: 

Free-RTOS on STM32L151C6 using STM32CubeMX [Timing issue]

SProg
Associate III

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.

1 REPLY 1
SProg
Associate III

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.