2017-08-09 08:12 PM
I am trying to code interval timer for stm32f410 nucleo demo board.
Following is the code wherein I try to set the on-board LED-2 GPIO_PIN_5 as indication but till now no success
Please following is the code ....need some help here.
Code:
/*******************************************************************************************************/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){ HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,1); while(1); __HAL_TIM_CLEAR_FLAG(&TimHandle,TIMx_CC_IRQn);}/*******************************************************************************************************/int timer_init1(){ uint32_t uwPrescalerValue = 0; uwPrescalerValue = (uint32_t) ((SystemCoreClock /2) / 50000) - 1; TimHandle.Instance = TIMx; TimHandle.Init.Period = 1; TimHandle.Init.Prescaler = uwPrescalerValue; TimHandle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;__HAL_TIM_CLEAR_IT(&TimHandle, TIMx_CC_IRQn);
HAL_NVIC_SetPriority(TIMx_CC_IRQn, 0, 1); HAL_NVIC_EnableIRQ(TIMx_CC_IRQn);if(HAL_TIM_Base_Init(&TimHandle) != HAL_OK){
Error_Handler(); }if(HAL_TIM_Base_Start_IT(&TimHandle) != HAL_OK){
Error_Handler(); } return 0;}/*******************************************************************************************************/void init_io(){ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); }/*******************************************************************************************************/
int main(void){ HAL_Init(); SystemClock_Config(); __HAL_RCC_GPIOA_CLK_ENABLE();__enable_irq();
init_io();
timer_init1();
while(1){ } }Thanks,
-aditya Patil
#timer #smt32-nucleo #interrups2017-08-10 04:15 AM
Hello,
maybe you can add some more information?
Some observations I made in your code:
Are you using CubeMX to generate the initial code, or where did you get that from?