My program enters in the ADC Interrupt but I can´t reset EOC flag. What is the matter with my code? void ADC_IRQHandler(void) { IT_tick=1; ADC1ConvertedValue = ADC1->DR; /* Dato convertido */ ADC1->SR &=~ 0x0000001F; /* DOESN´T WRITES SR */ /* ADC_ClearITPendingBit(ADC1, ADC_IT_EOC); */ /* DOESN´T WRITES SR EITHER*/ }
Thks for replying. I´d read that but it doesn´t works. My code is the following one:
void ADC_IRQHandler(void) { IT_tick=1; ADC1ConvertedValue = ADC1->DR; /* READ. IT DOESN´T CLEAR EOC Flag*/ ADC1->SR &=~ 0x00000002; /* DOESN´T WRITES SR, SO DOESN´T CLEAR EOC Flag */ ADC_ClearITPendingBit(ADC1, ADC_IT_EOC); /* LIBRARY FUNCTION. DOESN´T WRITES SR EITHER */ } Must i do anything else to clear this bit? My programm stays in the ISR ever.
You need to read the Manual RM0008. EOC: End of conversion: This bit is set by hardware at the end of a group channel conversion (regular or injected). It is cleared by software or by reading the ADC_DR. The EOC bit is of type ''read/clear (rc_w0)'' Software can read as well as clear this bit by writing 0. Writing ‘1’ has no effect on the bit value. So you must write a zero directly to the register to clear the bit. John F.
ADC status register (ADC_SR) Bits 31:5 Reserved, must be kept cleared.
ADC1->SR &=~ 0x00000002; isn't the same as ADC1->SR = 0x0000001D ... and you should clear the ADC pending bit using ADC_ClearITPendingBit() function in your ADC routine too of course! John F.
Continuousmode off means there is one sampling & conversion. So it enters ISR andthen stops u need to trigger ADC once again by usingADC_SoftwareStartConvCmd(ADC1, ENABLE); .
Continuousmode on it triggers interrupt on each (group) conversion done. Conversions are made in infinite row.Going more deeply according that you are using 72Mhz clock your ADC clock is:
So each1,5us you have new value and EOC flag is set. More or less its very short timeand you need to do all your math in this time otherwise next eoc flag is setand may not enter main loop at all. Let’s mention that interrupt latency is 12cycles.
Do youreally need that frequent short time sampling? I bet you want short timesampling but not that frequent than use that continuous mode for sake of simplicityand additional timer to read values. Don’t use EOC flag.
That is theway I see it i might be wrong just starting with stm32.