cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L0: Problem with adc multichannel

danilo23
Associate
Posted on March 04, 2015 at 15:18

Hello,

I want to read several voltages with the adc of the STM32L051K8.

If I convert only one channel, then the value is correct, but if it convert several channel is has an incomprehensible behavior.

Sometimes it says every channel has the same value or the assigment of the values to the channels is incorrect.

It seems to be an problem with the channel multiplexing.

Is there something to consider before changing the activ adc channel?

You can find the program code as attachment and an example output below.

(Annotation: The functions UART_sendString and UART_intToString are defined in other files, but works without problems)

Example Output:

Value1: 0xFFFF (it's should be 0x00FF)

Value2: 0x0FFF (correct)

Value3: 0x00FF (it's schould be 0x0FFF)

Value4: 0xFFFF (correct)

Value5: 0x0FFF (it's should be 0xFFFF)

Thanks for your help

Danilo

2 REPLIES 2
Posted on March 04, 2015 at 16:58

In all other STM32 designs the ascribed method for doing multiple channels is to program the ADC with a list and use DMA.

Without deinitializing the ADC I'd assume your method just adds channels to a list. You could read out the ADC registers and decipher what it thinks you've done if the behaviour perplexes you.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
danilo23
Associate
Posted on March 04, 2015 at 18:31

Thank you very much for your answer, you saved my day.

You are right, the mistake was to think, that every channel configurations overwrites the old one and selects only the new channel. In truth it adds the new channel to a sequence.