2015-08-05 02:37 AM
STM32F407VG
When Interrupt function looks like this:void ADC_IRQHandler(void)
{
adc=HAL_ADC_GetValue(&hadc1);
HAL_ADC_IRQHandler(&hadc1);
HAL_ADC_Start_IT(&hadc1);
}
Everything works well.
But when I want to do the ADC conversion one by one.( hadc1.Init.ContinuousConvMode = ENABLE;)
void ADC_IRQHandler(void)
{
adc=HAL_ADC_GetValue(&hadc1);
HAL_ADC_IRQHandler(&hadc1);
// HAL_ADC_Start_IT(&hadc1);
}
OVR bit in the SR register is set and ADC is not working.
As the end of conversion, we get to ADC_IRQHandler, collect our data .All right. Bit OVR shall not be installed so as we all do in time.
I have to constantly reset the OVR bit or make the setting(hadc1.Init.EOCSelection = EOC_SEQ_CONV;) and then the OVR bit
will not be installed.
ADC conversion
againworks well.
Why OVR bit is set?
#discovery #adc #stm32f42015-08-05 08:43 AM
Hi britwa.boris,
In the ADC IRQ handler, you should only call AL_ADC_IRQHandler().The other functions have to be added in your main.Refer to some examples in the Cube package to know the proper way to do it.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2015-08-06 04:44 AM
thanks for the answer
if I addfunction
inside ADC_IRQHandler
I receive an error
Configuration.axf: Error: L6218E: Undefined symbol AL_ADC_IRQHandler (referred from stm32f4xx_it.o).Perhaps
the ADC
is faster
than
interrupt handling
because
OVR bit in the SR register is set and ADC is not working?To use
the conversion
one by one
, I need toreduce the speed of
the ADC
register
ADC_SMPRx ?
2015-08-06 05:25 AM
HAL not AL ?
2015-08-06 05:58 AM
void ADC_IRQHandler(void)
{ /* USER CODE BEGIN ADC_IRQn 0 */ // i=HAL_ADC_GetValue(&hadc1); i=ADC1->DR;//faster /* USER CODE END ADC_IRQn 0 */ HAL_ADC_IRQHandler(&hadc1); /* USER CODE BEGIN ADC_IRQn 1 */ HAL_ADC_Start_IT(&hadc1) ; /* USER CODE END ADC_IRQn 1 */ }Once again,
it all
works
.Now I want to do the ADC conversion one by one.( hadc1.Init.ContinuousConvMode = ENABLE;)
void ADC_IRQHandler(void)
{
i=ADC1->DR;//faster
HAL_ADC_IRQHandler(&hadc1);
// HAL_ADC_Start_IT(&hadc1);
}
OVR bit in the SR register is set and ADC is not working
.Is this possible
without using
DMA
only
using
the interrupt
,intime
to collect
the data?
2015-08-06 09:49 AM
You acquire your data at which frequency? It is a fact that the DMA is transferring data and setting back the ADC faster than you will do . That is his purpose.
If you have a speed problem why not using the DMA and the HAL_ADC_ConvCpltCallback() function? Just saying.2015-08-06 11:34 AM
Keaven
HAL_ADC_ConvCpltCallback()this is an empty
function,
which is called
if the conversion
right.
It is
does not help
.''HAL_ADC_ConvCpltCallback could be implemented in the user file''
how to use it in main()
?I
'll try toreduce the
clock
valuefor bus APB2 .
2015-08-07 11:19 AM
Here is a link https://youtu.be/0-bys4N3wg0
I have tried
to
reduce the
clock
valuefor bus APB2 --
NO RESULT.All
works but
each time
I have to
reset
bit
OVR
.How to adjust
the conversion
one by one
with the
interruptthat
bit
OVR
was not present
?2015-08-07 11:45 AM
In continuous mode you're going to have to conscious of the conversation time you've selected. If it's very aggressive, how are you going to service it quickly, especially with all the overhead HAL adds to the mix.
Suggest as an experiment you self pace this. Turn off continuous mode, and then toggle an LED/GPIO in the interrupt, and start the next conversion after you read the current one. The signal on a scope should let you understand what your saturation point is for your implementation.Normally, you use DMA, and collect lots of results, before you interrupt. And you trigger the conversion with a timer so you have a consistent timebase for the samples in the time domain.2015-08-08 10:14 AM
Conversion
one by one,
with the interruption
at the end of
the conversion.
ADC
operates at
50
MHz
.All
works !!!
I will soon lay out
a video
.