Hello. I face the following situation:
A STM32 (STM32H7B0 in my case, though if a general solution exists, all the better) is connected via a limited number of lanes (say, 8 ) to a board with analog sensors, that has e.g 32 analog values to report continuously. I would like to get continuous readings of these sensors with no involvement from the CPU past setting things up.
I design both the main (with MCU) and peripheral (with sensors) boards.
By adding analog multiplexers on the peripheral board, things fit, 2 lanes for power, 1 lane for analog, 5 lanes for channel selection: you can read all 32 signals.
The issue is then, how to automate the acquisition of sensor values ? Ideally we would want the multiplexer channel to be endlessly swept (the 5 channel selection lanes to automatically present a %32 counter), to connect the ADC to the DMA in an endless conversion mode, typically to a ring buffer of the appropriate size, in such a fashion that the sensor ID - memory location pairings be constant.
Assuming no oversampling, since the multiplexer has a transition period (much lower than the ADC conversion period), we would like to end up with the following in memory:
[reading for channel 0b00000]-[thrown away]-[reading for channel 0b00001]-[thrown away]-[reading for channel 0b00010]-[thrown away]-[reading for channel 0b00011]-etc.
One way I can imagine this working is by synchronizing the PWM and the ADC. If every channel is launched at the same time as the ADC conversion, with a period the appropriate multiple of the ADC conversion period, and things don't drift (as far as I know, nothing in this isn't synchronous to a clock, so no reason for anything to drift), the PWM can output what's effectively a counter over arbitrary digital lanes, accomplishing what precedes.
I am not sure how to do this however - I'm not very familiar with clocks and synchronization in embedded. Is it possible to bind PWMs and the ADC to the same clock and ensure that they all start synchronously ?
How do I even do this considering their control registers are separate ?
Or can I maybe bind them to a clock and configure them appropriately then control the clock start-up myself - perhaps by generating my own clock signal via PWM to feed back into them somehow ?