AnsweredAssumed Answered

CubeMX IRQHandler does not clear up interrupts

Question asked by yazdani.saeid on May 28, 2015
Latest reply on Jun 11, 2015 by Higetaka
Hi all!

I used  CubeMX to generate a simple project where there are 3 buttons and 3 leds are connected to my STMF103RBT6.

I want to use interrupt, but the code generated by CubeMX is not clearing up any interrupts. Here is the original generated code:

void EXTI15_10_IRQHandler(void)
{
  /* USER CODE BEGIN EXTI15_10_IRQn 0 */
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_12));
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13));   
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_2, HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_14)); 
  /* USER CODE END EXTI15_10_IRQn 0 */
 
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_12);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_14);
 
  /* USER CODE BEGIN EXTI15_10_IRQn 1 */
   
  /* USER CODE END EXTI15_10_IRQn 1 */
}

So I want to do is turn each corresponding LED whenever a button is pressed. Using the code above, only the button on GPIO_PIN_14 works, no matter what, 23 and 13 does not work:

void EXTI15_10_IRQHandler(void)
{
  /* USER CODE BEGIN EXTI15_10_IRQn 0 */
   
  if(__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_12) != RESET)
  {   
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_12));
    __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_12);
    return;
  }
   
  if(__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_13) != RESET)
  {
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13));
    __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_13);
    return;
  }
   
   
  if(__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_14) != RESET)
  {
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_2, HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_14));
    __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_14);
    return;
  
   
  /* USER CODE END EXTI15_10_IRQn 0 */
   
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_12);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_14);
   
  /* USER CODE BEGIN EXTI15_10_IRQn 1 */
   
  /* USER CODE END EXTI15_10_IRQn 1 */
}


I tried to lend code from a NOT CubeMX library, but it does not work. What I am endded up with is something like this, but it still does not work! I would be happy if you can point out what am I doing wrong. (I have tested all buttons and leds without using interrupts and they are fine! so I guess the problem is in the IRQHandler).

Outcomes