2019-12-14 02:26 PM
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.
2019-12-15 02:29 AM
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.