cancel
Showing results for 
Search instead for 
Did you mean: 

Setting interrupt ADC conversion is complete using HAL

borisbritwa13
Associate III
Posted on August 05, 2015 at 11:37

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

again

works well.

Why OVR bit is set?

#discovery #adc #stm32f4
15 REPLIES 15
Amel NASRI
ST Employee
Posted on August 05, 2015 at 17:43

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.

borisbritwa13
Associate III
Posted on August 06, 2015 at 13:44

0690X0000060MnFQAU.gif

thanks for the answer

if I add

function

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 to

reduce the speed of

the ADC

register

ADC_SMPRx ?

Posted on August 06, 2015 at 14:25

HAL not AL ?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
borisbritwa13
Associate III
Posted on August 06, 2015 at 14:58

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

,in

time

to collect

the data?

keaven
Associate II
Posted on August 06, 2015 at 18:49

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.

borisbritwa13
Associate III
Posted on August 06, 2015 at 20:34

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 to

reduce the 

clock

value 

for bus APB2 .

borisbritwa13
Associate III
Posted on August 07, 2015 at 20:19

Here is a link  https://youtu.be/0-bys4N3wg0

I have tried

to

reduce the 

clock

value 

for 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

 interrupt

that

bit

OVR

was not present

?

Posted on August 07, 2015 at 20:45

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
borisbritwa13
Associate III
Posted on August 08, 2015 at 19:14

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

.