Generate Software Interrupt (SI) with STM32F· Discovery board with HAL drivers
Hi everyone,
I’m trying to work with software interrupts with my STM32F3 Discovery board. What I’m doing is, first of all, generate a 1 KHz signal with a timer. This signal works well, my problem is generating a SI each time the timer activates its callback. My code is the following:
/* USER CODE BEGIN 0 */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
if(htim->Instance == TIM3){
HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_1);
contador_timer++;
if (contador_timer == 100){
contador_timer = 0;
HAL_GPIO_TogglePin(GPIOE,GPIO_PIN_10);
__HAL_GPIO_EXTI_GENERATE_SWIT(EXTI_SWIER_SWIER0);
}
}
}
/* USER CODE END 0 */
The last macro, HAL_GPIO_EXTI_GENERATE_SWIT(), is supose to activate a software interrupt in the line especified, in this case line 0 (EXTI_SWIER_SWIER0).
To control this line, I have a function like this:
void EXTI0_IRQHandler(void)
{
/* USER CODE BEGIN EXTI0_IRQn 0 */
if (__HAL_GPIO_EXTI_GET_IT(EXTI_SWIER_SWIER0) != RESET){
HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_2);
osDelay(200);
}
}
I’m trying to generate a change on GPIO in PC2 every 200 ms, but with this code the output is a signal of 25 KHz period and I don’t know why.
Can anyone help me with this problem? Thank you in advance for your time.
Best regards.
Andreas