I use SW4STM32 toolchain,I want to bliking led using timer2 when overflow, in STM32103RET, here is my functions to turn led on and of.
void TurnOnLed(){
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_10,GPIO_PIN_SET);
}
void TurnOffLed()
{
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_10,GPIO_PIN_RESET);
}
the timer2 initilizing has been set by stm32 cube mx, but i do not know which function called when timer2 overflows?
You need to start your timer by function
HAL_TIM_Base_Start_IT(&htimX);
And for the firs time implement you callback function named HAL_TIM_PeriodElapsedCallback
:
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if (htim->Instance == TIMx) {
}
}
If you don't know anything about HAL_Driver you may found a lot of information from:
HAL Driver
on st.comC:/Users/%USERNAME%/STM32Cube/Repository/
directory)stm32f?xx_hal_tim.c
and see what functions are present, see their comments to uderstand what tey are doing. And see what functions are called from HAL_TIM_IRQHandler
to know how are named callbacks.