cancel
Showing results for 
Search instead for 
Did you mean: 

using STM32CUBEide timer in freeRTOS not working

hjh
Associate III

Hi

Making a very simple freeRTOS project with only one timer on a bluepill

the LED is blinking with 1000 hz = tick rate and not with 1 hz as programmed ...

What did i do wrong ?

 /* Create the timer(s) */

 /* definition and creation of myTimer01 */

 osTimerDef(myTimer01, Callback01);

 myTimer01Handle = osTimerCreate(osTimer(myTimer01), osTimerPeriodic, NULL);

 /* USER CODE BEGIN RTOS_TIMERS */

 xTimerStart(myTimer01Handle,1000);

 /* USER CODE END RTOS_TIMERS */

/* Callback01 function */

void Callback01(void const * argument)

{

 /* USER CODE BEGIN Callback01 */

HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);

osDelay(50);  //// this just to reduce the blink freqvenzy so i can see it do blink

 /* USER CODE END Callback01 */

}

1 REPLY 1
hjh
Associate III

solution was to do xstarttimer in default task

void StartDefaultTask(void const * argument)

{

 /* USER CODE BEGIN 5 */

 osTimerStart(myTimer01Handle,1000);

 /* Infinite loop */

 for(;;)

 {

 osDelay(1);

 }

 /* USER CODE END 5 */ 

}

but then CUBEMX are not correct because it says

 /* Create the timer(s) */

 /* definition and creation of myTimer01 */

 osTimerDef(myTimer01, Callback01);

 myTimer01Handle = osTimerCreate(osTimer(myTimer01), osTimerPeriodic, NULL);

 /* USER CODE BEGIN RTOS_TIMERS */

 /* start timers, add new ones, ... */

 /* USER CODE END RTOS_TIMERS */

START TIMERS ...that is wrong !!!!

Hjalmar