AnsweredAssumed Answered

Freertos and HAL external interrupts

Question asked by rolly loysney on Nov 9, 2017
Latest reply on Nov 11, 2017 by Zhitai Liu


I'm using stm32l496.


i'm trying to control LEDs with pwm through freeRTOS and using external Interrupts (gpio buttons)


i have some questions :


  i have some tasks looping while(1) to detect my input GPIO  and launch PWM timer :


void TASK(void)




        if(HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_1) == GPIO_PIN_SET)

            HAL_TIM_PWM_Start(&htim16, TIM_CHANNEL_1);

            while(HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_1) == GPIO_PIN_SET) 

                  __HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, 2000);

                  __HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, 0);



i'm using 10 tasks like this to activate leds on demand.



Sometimes, the PWM led doesn't start though.

i guess there is better way using External Interrupts right ?


When i use external input EXTI0_IRQHandler() to do same task

it crashes freertos.


when i use theEXTI0_IRQHandler() without freertos activated, in another project, it works.


How to correctly use external interrupts with freertos ? or correctly launch my timers within tasks ?


I guess my program is too much time consuming and it lags...


Thank you