Freertos and HAL external interrupts
Hello,
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)
{
while(1)
{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); osDelay(200);;__HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, 0);
osDelay(200);}}
}
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 the
EXTI0_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
#gpio-interrupt #pwm #freertos+hal