cancel
Showing results for 
Search instead for 
Did you mean: 

stm32L476 12 Bit ADCs causing Spikes in Data

Bene Sch
Associate II
Posted on January 30, 2017 at 19:29

Hi there,

I am using the Stm 32L476 and I am trying to use 2 ADCs with 2 channels each with 12 Bit. So 4 Channels all together. I am using the ADCs in Regular simultanuous  multimode with DMA so I am able to transmit the data from  DMA to USART afterwards.

Now I encountered a problem, that sometimes I get spikes of almost 255 Bits in my data.

In Matlab I receive the data, so 2 Bytes for each ADC.  The spikes happen, when the Byte with the LSB has an overflow.

One example with two consecutive ADC values consisting of two bytes:

1.)00000110  01111100      (6   252)

2.)00000110  00000000     (6    0)

It seems like the ADC transmits the first byte with the MSB and after that it gets an overflow in the second one, but cant correct it in the first byte. The next ADC value has the corrected first Byte. So each spike always consists of only one value.

If I use the ADCs with 12,5 Cycles sampling time and with a prescaler of 64 (f=16MHz), it works fine and I cannot see any spikes.  Nevertheless it would be nice if I can run the ADCs faster...

Can somebody imagine what goes wrong here?

Thanks a lot in advance!

#multimode #spikes #12bit-adcs #overflow #stm32l476
7 REPLIES 7
Posted on January 30, 2017 at 21:55

>  I am using the ADCs in Regular simultanuous  multimode with DMA

How exactly?

> so I am able to transmit the data from  DMA to USART afterwards.

So you *don't* use Circular mode in DMA, wait until DMA finished, transmit data through USART without re-enabling the DMA, right?

JW

Posted on January 30, 2017 at 22:43

Hi,

Thank you for your answer first!  I run them in scan mode and cont. conversation mode. Channel 1 and 3 with adc 1 and 2 and 4 with adc 2. Tomorrow I will upload the code. 

I run them in circular mode. And in the conversion complete  callback I transmit the data via uart, which runs in normal mode.

Thank you,

Bene

Posted on January 30, 2017 at 22:46

I run them in circular mode. And in the conversion complete  callback I transmit the data via uart, which runs in normal mode.

OK so how do you know the DMA from ADC is not overwriting the buffer while you are transmitting via UART?

JW

Posted on January 31, 2017 at 07:46

Ah ok... This could be the problem. Thank you! So could I start the ADCs in normal-mode again in th

HAL_UART_TxCpltCallback ? Or is there a better solution? DoubleBuffering?

Posted on January 31, 2017 at 12:02

Ok! I did it now like this:

StartMultimode in main()

StopMultimode and Start Transmit via UART  in the ADC_Conversion_Complete_Callback

StartMultimode in UART_Transmit_Callback

Like this it works.  Is it ok like this or is there even a better possibility?

Thanks a lot!
Posted on January 31, 2017 at 12:05

Probably it's OK but I don't Cube so I can't help you with the Cube-related details.

JW

Posted on January 31, 2017 at 13:28

Ok. No problem! Thank you a lot!