2017-03-10 01:43 PM
I'm trying to setup 3 ADCs to read on a timer tick. On the STM32cube the timer can be set to 'Output Compare' to a single channel. And the ADC's can be set to external trigger conversion on a 'Timer Capture Compare # Event' Finally in the specific settings after a timer has been enabled, the timer can have a trigger event selection. If i'm trying to synch 3 ADCs to all write to separate buffers, what settings do i need to achieve that ?
2017-03-10 03:59 PM
separate buffers require separate DMAs.
page 404 of RM0090
13.9 Multi ADC mode
In devices with two ADCs or more, the Dual (with two ADCs) and Triple (with three ADCs)ADC modes can be used (see Figure 51).In multi ADC mode, the start of conversion is triggered alternately or simultaneously by theADC1 master to the ADC2 and ADC3 slaves, depending on the mode selected by theMULTI[4:0] bits in the ADC_CCR register.Note: In multi ADC mode, when configuring conversion trigger by an external event, theapplication must set trigger by the master only and disable trigger by slaves to preventspurious triggers that would start unwanted slave conversions.The four possible modes below are implemented:• Injected simultaneous mode• Regular simultaneous mode• Interleaved mode• Alternate trigger modeIt is also possible to use the previous modes combined in the following ways:• Injected simultaneous mode + Regular simultaneous mode• Regular simultaneous mode + Alternate trigger modeNote: In multi ADC mode, the converted data can be read on the multi-mode data register(ADC_CDR). The status bits can be read in the multi-mode status register (ADC_CSR).2017-03-10 05:30 PM
Thanks Nick, so since all the ADCs are connected to DMA2, i'm required to use one buffer to write all 3 of them to (if i want simultaneous writing to buffers)?
So if that's the case i originally had multi (3 ADCs) mode working, but i couldn't seem to get the MemtoMem DMA working where i could get it to automatically transfer each portion (since triple mode writes each value as (ADC1 | ADC2 | ADC3 | ADC1 ...) to thier own separate buffer after the fact. I don't know if you know how to accomplish that, or if i should just write all the data to flash and post-process the data to it's correct, separate, columns?
Additionally, Would you mind detailing how to sync a single ADC to a timer to write thru DMA? Meaning I've got an internal clock synced timer so that the ADC writes to a buffer from DMA while synced to a clock. Could i use that same method to synch the triple mode to a single timer? Thanks for the response regardless!
2017-03-10 06:09 PM
Hi again,
in CubeMX
you can set up three streams all using DMA2
ie ADC1,ADC2 and ADC3 all using DMA2 but to pump data to different memory locations.
Do you use HAL ?
I can only use STM32F0xx series here, so I am not sure I can help much more than this.
I will attach a STM32F427 Cube test file in the next window, since it will take 10 hours for the moderation to approve it...
2017-03-10 06:13 PM
CubeMX file to DMA 3 ADCs
________________ Attachments : F427ZIT 3 DMA ADCs .ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyoQ&d=%2Fa%2F0X0000000bCi%2Fz5tG2mHOSkiw2ROe_ew.1D9gKX71YtW1XoWJovkSLpw&asPdf=false2017-03-10 08:06 PM
yes., I think you can automate the process by making the mast ADC trigger off the Timer and then the slave ADCs to trigger from the master.
2017-03-10 08:36 PM
This is great! thank you so much!. Do i need to set the conversion source for the ADCs to a timer to enforce the DMA to to sync with the timers? I'm talking about under Configuration | ADC | ADC_Regular_Conversion_Mode | External Trigger Conversion Source. I assumed this was what synced the ADC with the Timers. As always thank you so much for the help.
2017-03-10 09:12 PM
,
,
Ok, i'm gonna put this out to clarify, i assume that under '
Configuration | ADC | ADC_Regular_Conversion_Mode | External Trigger Conversion Source' the selection 'Timer ♯ Capture Compare ♯ Event' means: Whatever timer you choose, the 2nd number is the amount of ticks it looks for from the 'Output Compare' event from the selected timer. I.E. Timer 1 Capture Compare 2 event means it looks for two ticks before it writes one value from the ADC over DMA to memory.
2017-03-10 09:20 PM
the timers have many output compare channels, usually 4 on some timers, less on others.
it is the second channel.
every time the selected output compare timer channel is matched to the timer counter, the ADC will fire.
you can fire all 3 ADC's off the same Timer Output compare channel if you like.
2017-03-11 08:05 AM
Ok, so the 'Capture Compare ♯' Is the channel of which it's getting it's ticks from, NOT the amount of ticks it needs per conversion. I.E. if i chose Timer 5 Capture Compare 1 Event, it's doing a DMA transfer from the ADC every tick sent by Timer 5 to Channel 1?