2020-12-03 01:04 AM
Hi. I have two sensors connected to an STM32f410r8t6, where they send a high signal whenever new data is ready to be read.
Pin connections are as follows:
PC9 (GPIO_EXTI9) -> INT_IMU2
PC7 (GPIO_EXTI7) -> INT_IMU1
I have them setup as follows in the ioc file.
The GPIO and NVIC code is automatically generated.
In my stm32f4xx_it.c file I have the following:
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_7);
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9);
/* USER CODE BEGIN EXTI9_5_IRQn 1 */
/* USER CODE END EXTI9_5_IRQn 1 */
}
So I navigate to the HAL_GPIO_EXTI_IRQ_Handler function.
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);
}
}
I see that I must implemented the code I wish to be executed in the interrupt within the HAL_GPIO_EXTI_Callback function. I head back to main and insert this: under user code begin 4:
void HAL_GPIO_EXTI_CALLBACK(uint16_t GPIO_Pin)
{
//if (GPIO_Pin == INT_IMU1_Pin) //IMU1 has sample ready
if (GPIO_Pin == GPIO_PIN_9)
{
HAL_GPIO_TogglePin(LED_3_GPIO_Port, LED_3_Pin);
Entered_ISR = 1;
/*
ICM_ReadAccelGyroData(&IMU1);
ICM_ReadAccelGyroData(&IMU2);
filterUpdate(&IMU1);
filterUpdate(&IMU2);
*/
}
//else if (GPIO_Pin == INT_IMU2_Pin) //IMU2 has sample ready
else if (GPIO_Pin == GPIO_PIN_7)
{
HAL_GPIO_TogglePin(LED_3_GPIO_Port, LED_3_Pin);
Entered_ISR = 1;
/*
ICM_ReadAccelGyroData(&IMU1);
ICM_ReadAccelGyroData(&IMU2);
filterUpdate(&IMU1);
filterUpdate(&IMU2);
*/
}
}
When I debug the program, it never enters the interrupt routine. The flag isn't set, and the LED doesn't toggle.
Looking at the line with an oscilloscope I see that the pulses are there:
The high signal is 2.5 V, which should be high enough, as the datasheet for the MCU specifies 0.7*VCC is accepted as V_Hin, and the MCU is supplied with 3.3 V
What stupid thing am I missing?
2020-12-03 06:09 AM
Debug as usually, i.e. read out and check/post the relevant GPIO, EXTI, NVIC registers content. Observe EXTI registers if the pulse is captured. Make sure the ISR is properly inserted in the vector table, best in disasm.
JW
2020-12-03 06:15 AM
Hey Jan.
Thanks for your reply. I found the error half an hour ago, turns out I had written my callback function in all caps. CALLBACK instead of Callback resulted in the function never executing.