2015-03-04 06:18 AM
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 Danilo2015-03-04 07:58 AM
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.2015-03-04 09:31 AM
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.