cancel
Showing results for 
Search instead for 
Did you mean: 

I am writing AC Dimming code with Zero cross detection as an External interrupt but it is not working as expected.

#include "main.h"
 
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
int main(void)
{
  HAL_Init();
  SystemClock_Config();
  MX_GPIO_Init();
  while (1)
  {
  }
}
 
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
    if(GPIO_Pin == GPIO_PIN_9) // If The INT Source Is EXTI Line9 (A9 Pin)
    {
	HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_10); // Toggle The Output (LED) Pin
    }
}

1 REPLY 1
TDK
Guru

The code you posted looks fine. There's a lot of other code that isn't shown that is required to make it work, but CubeMX should generally set that up for you. The EXTIx_IRQHandler should be called which will then call a HAL function to handle the interrupt.

Include some more details on what you've tried and what "isn't working" means in particular.

If you feel a post has answered your question, please click "Accept as Solution".