Code taking way longer than expected, looks like IRQs firing but they aren't mine - how to debug?
I've got some code running on the C4 in an STM32H747IGT6, it's just waiting for the ADC to have data and then reading it:
while (!LL_ADC_IsActiveFlag_EOC(ADC1)) {}
__disable_irq();
start_timer = TIM5->CNT;
LL_ADC_ClearFlag_EOC(ADC1);
adc_data = LL_ADC_REG_ReadConversionData32(ADC1);
data = ((float)adc_data) / 65536.0f; // Normalize from 0..0xFFFF (-4 to 4V) to 0..1
end_timer = TIM5->CNT;
uint32_t icsr = SCB->ICSR;
__enable_irq();With IRQs disabled (as shown here), TIM5->CNT shows the code takes 6-8 ticks but if I comment out the calls to __disable_irq() and __enable_irq(), the code takes as many as 146 ticks and I'm trying to figure out why. TIM5 has no interrupts enabled and is running at full speed (240 MHz) so ticking once every 4.1666 ns.
If I look at the value of SCB->ICSR it's almost always 0x400000 which means ISRPENDING but VECTPENDING is zero.
In my code I'm only enabling 3 interrupts and I've verified none of them are firing.
How can I figure out which interrupts are firing and slowing me down so much?
