AnsweredAssumed Answered

Question about interrupt debugging in IAR

Question asked by Kefei Yao on Apr 23, 2018

I'm using STM32F103 and I was doing the following procedures:

1) Break the execution using IAR debug function

2) Generate a software EXTI by wring "1" to the EXTI->SWIER9

3) Observe the EXTI->PR9 become "1" which is correct

4) Clear the EXTI->PR9 by writing "1" to it

5) Step the execution

6) The execution goes into the ISR for External inerrupt 9, which is correct

7) In the ISR context, it will judge the EXTI->PR9 again to check if it's SET. 

8) Surprisingly, the code in red read EXTI->PR9 as SET and execute the code which is marked in green.

I am wondering why? Because from IAR, I clearly read EXTI->PR9 as 0 (because I set it to zero in step 4).

void EXTI9_5_IRQHandler(void)
{
/* USER CODE BEGIN EXTI9_5_IRQn 0 */

/* USER CODE END EXTI9_5_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9);
/* USER CODE BEGIN EXTI9_5_IRQn 1 */

/* USER CODE END EXTI9_5_IRQn 1 */
}

 

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);
}
}

Outcomes