Skip to main content
Dharmendra Savaliya
Visitor II
September 4, 2020
Question

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

  • September 4, 2020
  • 1 reply
  • 820 views
#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
 }
}

This topic has been closed for replies.

1 reply

TDK
September 4, 2020

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""."