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-09 09:51 AM
�?t the end of
thevideo conversion
one by one with
interrupt
Thanks to all
for the help
!!!!2015-08-10 08:38 AM
''HAL_ADC_ConvCpltCallback could be implemented in the user file''
how to use it in main()
?Simply add it to your source file and add your code to it. Those functions are ''weak'' type they are like a virtual type function. All callbacks of HAL library works that way.
2015-08-11 01:34 AM
britwa.boris
.
Could you provide
your
ADC
Setup function
?
As explained
Keaven
,
HAL_ADC_ConvCpltCallback
function must be
implemented in
your main program
after the
main ()
your
ADC
interrupt
function should
look exactly like
:
ADC_IRQHandler
void
(void)
{
HAL_ADC_IRQHandler
(
&
AdcHandle
)
;
}
I suggest you
take a
look
at the
example
program in the
repository
CubeMx
C: \
Users \
username \
STM32Cube
\
Repository
\
STM32Cube_FW_F4_V1.7.0
\ Projects
\
STM32446E_EVAL
\ Examples
\
ADC
Good luck
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-11 09:42 AM
rrom
catch
/* ADC1 init function */ void MX_ADC1_Init(void) { ADC_ChannelConfTypeDef sConfig; /**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) */ hadc1.Instance = ADC1; hadc1.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2; hadc1.Init.Resolution = ADC_RESOLUTION12b; hadc1.Init.ScanConvMode = DISABLE; hadc1.Init.ContinuousConvMode =ENABLE; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc1.Init.NbrOfConversion = 1; hadc1.Init.DMAContinuousRequests = DISABLE; hadc1.Init.EOCSelection = EOC_SINGLE_CONV; HAL_ADC_Init(&hadc1); /**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_1; sConfig.Rank = 1; sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; HAL_ADC_ConfigChannel(&hadc1, &sConfig); }''HAL_ADC_ConvCpltCallback could be implemented in the user file''-
well
understood.
2015-08-11 11:45 PM
I suggest you
tofollow the
recommendations
of Clive1
.
A
very aggressive
timming
perspective
thus
he goes into
overrun
error.
What
conversion
rate
do you need?
Maybe
you should
trigger your
ADC
conversion with
a timer
and capture
the result in your
HAL_ADC_ConvCpltCallback
()
Or
use DMA
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-12 10:39 AM
I
wrote above
that everything works
topic is closed!!!!
�?t the end of
thevideo conversion
one by one with
interrupt