Simple ADC read (DMA mode on STM32F4xx) and store to variable

hi all

i designed myself a little module around the core of clouds hardware (basically it’s only the codec and CPU left from the original HW)
i exchanged the user interface with a 5x7 dotmatrix display, and one single encoder with pushbutton.
only 2CV-IN Jacks and the two Audio IN/OUT from the codec.

my goal is to learn about the stuff thats happening, and maybe later on try to realise some own ideas in this digital world. i don’t wanna do such complex things (i think i am also far away from being capable to do so…)

for a start i try to get familiar with how the original code is built up. and i must say “chapeau!!” that is one very well organized and structured work. but hell of a complex thing for me too.

so far i managed to get my dotmatrix display to work and implement parts of graphic functions i used in older atmel projects i did.

i now wanna try to deal with the new UI. so it seems like i have to dig into ui.cc and ui.h

maybe anybody has a quick hint how to just make a quick test with reading an ADC (seems to be in DMA mode with tons of channels in the original) from one of the CV ins store it in a variable?

Use the existing ADC class.

Set your number of channels here:
https://github.com/pichenettes/modules/blob/master/clouds/drivers/adc.cc#L61
https://github.com/pichenettes/modules/blob/master/clouds/drivers/adc.cc#L87

Enumerate the ADC channel numbers you want to read here:
https://github.com/pichenettes/modules/blob/master/clouds/drivers/adc.cc#L91

Use adc_.float_value(0); and adc_.float_value(1); whenever you need to read an ADC value – in Ui::Poll() if you need them at UI refresh rate, or in FillBuffer if you need them at control (buffer) rate. Then immediately call adc.Convert() to launch the conversion in the background. The conversion will take a fraction of a ms so it’ll be done by the time Ui::Poll or FillBuffer is called next.

i initialized the adc in the main() and put the adc.Convert(); into the systick interrupt routine.
very cool - i can get some readings and spit them out on the uart allready.

i chose the input ampifier configuration for ±5V, i saw some neat defintions for the different input-amp-configurations somewhere in the code, let me search again…

but unfortunately my display shows only crap :slight_smile: seems like i need another itoa() like conversion routine to get something readable from the float for my buggy display driver…

thanks alot!!