Skip to main content
rtl
Associate II
December 12, 2024
Solved

EOCIE set, EOSIE not set, but EOS triggers and EOC doesn't

  • December 12, 2024
  • 3 replies
  • 1087 views

Hello!

I am having weird behaviour on my STM32G071 MCU.

I set up the ADC to measure in sequence and I want to get an interrupt when the sequence has finished. The ADC is set up with DMA and I am starting conversions manuallty within my loop that runs once a second.

In the interrupt handler I check for EOS and EOC. When I enable the EOS and EOC I get thousands of EOS interrupts in a second and no EOC interrupts.

When I enable the EOC and disable the EOS I get an EOS interrupt for every channel that I have in the sequencer, but no EOC interrupts. It seems like all the channels are measured during the interrupt, but I shouldn't even have these EOS interrupts. Although this kinda works for my application, this still isn't normal.

When I check the regs, the EOCIE is 1 and EOSIE is 0. I also added the reg data as a file. There you can see that the EOS flag is set, but the EOC is not, while EOCIE is set, but EOSIE is not.

My IRQHandler looks like this:

/**
 * @brief Interrupt handler for ADC.
 */
void ADC1_COMP_IRQHandler(void)
{
 if(ADC1->ISR & ADC_ISR_EOS)
 { 
 adc_seq_completed = 1;
 seq_it++;
 
 ADC1->ISR &= ~ADC_ISR_EOS;
 }
 
 if(ADC1->ISR & ADC_ISR_EOC)
 { 
 conv_it++;
 
 ADC1->ISR &= ~ADC_ISR_EOC;
 }
}

 Has anyone else experienced this? What could cause this?

This topic has been closed for replies.
Best answer by TDK

> ADC1->ISR &= ~ADC_ISR_EOS;

This clears all flags except EOS. If you want to clear EOS:

 

ADC1->ISR = ADC_ISR_EOS;

 

 

 

TDK_1-1734031618575.png

 

 

3 replies

rtl
rtlAuthor
Associate II
December 12, 2024

Did some more testing. When I start the ADC with DMA I get only one EOS IT and all channels are measured. Multiple ITs happen when I start a conversion manually by setting the ADSTART bit.

TDK
TDKBest answer
December 12, 2024

> ADC1->ISR &= ~ADC_ISR_EOS;

This clears all flags except EOS. If you want to clear EOS:

 

ADC1->ISR = ADC_ISR_EOS;

 

 

 

TDK_1-1734031618575.png

 

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
rtl
rtlAuthor
Associate II
December 13, 2024

Oh wow, thank you!