2025-09-01 11:14 AM
I'm using the AWD (STM32G0B0CE) with the HAL_ADC_LevelOutOfWindowCallback(), which works fine.
For not blocking the MCU completely, I'm disabeling the AWD-IT inside the Callback when fired for about 500ms:
LL_ADC_DisableIT_AWD1 (ADC1);
After the 500ms elapsed the AWD-IT is enabled again:
LL_ADC_EnableIT_AWD1 (ADC1);
This only works fine for about 2 times:
Start -> Fire IT -> DisableIT
-> 500ms
-> EnableIT -> Fire IT -> DisableIT
-> 500ms
-> IT stays completely disabled, though enabled again.
Any idea what I'm missing?
Thanks.
Solved! Go to Solution.
2025-09-07 5:59 AM
ADC_CR.ADSTART can't be cleared by writing 0 to it; you stop conversions by setting ADC_CR.ADSTP and that in hardware clears ADC_CR.ADSTART. This is not immediate, you are supposed to read back ADC_CR.ADSTP until it autoclears.
But I personally wouldn't do that. I would try to avoid triggering the interrupt by setting the watchdog thresholds so that no ADC result triggers it.
JW
2025-09-02 7:34 AM
> IT stays completely disabled,
How do you know? Have you observed the respective control flags in ADC? A generic "interrupt does not fire" guide here. As you appear to use Cube/HAL, the problem may be also in Cube/HAL's fabric, I don't use it but it's open source so you can check yoruself.
JW
2025-09-07 5:33 AM
ADC1->CR &= ~ADC_CR_ADSTART; // Clear ADSTART in ADC control register (ADC_CR)
ADC1->IER|=ADC_IER_AWD1IE; // Enable AWD-interrupt in ADC IR enable register (ADC_IER)
// LL_ADC_EnableIT_AWD1 (ADC1); // also doesn't work
ADC1->CR |= ADC_CR_ADSTART; // Set ADSTART in ADC control register (ADC_CR)
2025-09-07 5:59 AM
ADC_CR.ADSTART can't be cleared by writing 0 to it; you stop conversions by setting ADC_CR.ADSTP and that in hardware clears ADC_CR.ADSTART. This is not immediate, you are supposed to read back ADC_CR.ADSTP until it autoclears.
But I personally wouldn't do that. I would try to avoid triggering the interrupt by setting the watchdog thresholds so that no ADC result triggers it.
JW
2025-09-07 8:28 AM
Thanks for your idea!
This really sounds a better solution....