I want to understand that how Interrupt works in stm32f103c8t6(Blue pill).
I Did few things.
1: I used CubeMx to generate code with keil IDE
2: I made PC13 as Output to Toggle LED.
3: I made PA1 as Interrupt Pin(Button).
4: I called interrupt handler in main file under MX_GPIO_Init() function.
/* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
HAL_GPIO_EXTI_IRQHandler(Button_Pin); // by me5: when i went to the defination of HAL_GPIO_EXIT_IRQHandler() function.
i found call back function there and in that function i set my flag to ONE.
and I am using this flag into my while loop for LED blinking.
extern uint8_t Interrupt_Flag;
extern void LED(void);
extern uint8_t Interrupt_Flag;
/**
* @brief This function handles EXTI interrupt request.
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
{
/* EXTI line interrupt detected */
if (__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != RESET)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
HAL_GPIO_EXTI_Callback(GPIO_Pin);
}
}
/**
* @brief EXTI line detection callbacks.
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/
__weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(GPIO_Pin);
/* NOTE: This function Should not be modified, when the callback is needed,
the HAL_GPIO_EXTI_Callback could be implemented in the user file
*/
Interrupt_Flag = 1;
}After Doing all this I am expecting that when i give PA1 high my LED should be ON and at LOW it should be OFF.
But i am not getting output as i mention. I don't know where am i wrong.
So need your help. I tried on google but couldn't find any good example. which suits my need.