2021-07-27 08:16 PM
i want to measure the time an interrupt handler costs.
1. set a specified pin low at the beginning of the interrupt handler and high at the end of the interrupt handler like this:
void EXTI4_IRQHandler(void)
{
/* USER CODE BEGIN EXTI4_IRQn 0 */
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
/* USER CODE END EXTI4_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4);
/* USER CODE BEGIN EXTI4_IRQn 1 */
// ...
// codes omitted
// ...
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
}
2. measure the signal at the pin by an oscilloscope.
then the duration the signal keeps low is the time an interrupt costs.
is it possible to measure the duration in units of us?
Solved! Go to Solution.
2021-07-27 08:23 PM
Yep, that will work. You'll miss some overhead due to the ISR entry/exit and the HAL_GPIO_WritePin calls.
Another option would be to enable and use the debug DWT->CYCCNT timer which ticks at the system clock rate.
2021-07-27 08:23 PM
Yep, that will work. You'll miss some overhead due to the ISR entry/exit and the HAL_GPIO_WritePin calls.
Another option would be to enable and use the debug DWT->CYCCNT timer which ticks at the system clock rate.