Your ADC interrupt fires when all enabled channels have been converted. The results have been placed into an array from where you can read out the values. With DMA you can shovel those values (interleaved) to your desired location.
Is it possible for you to use a separate DMA components for all the channels? Then, you will be able to give different source address and loop those individually.
Thanks. I'm planning to try that as a workaround.
.But given that there's a whole system for automatically chaining ADC reads across 2 channels, there ought to be a way to read that out via DMA, this seems like the primary use case for the SAR ADC, one wouldn't expect to need a workaround! I'm wondering if maybe you're expected to use two adjacent registers and read it out as a 32 bit value?
i'm going to give both approaches a try when I get back from the holidays.
i'm just surprised everyone using this chip doesn't run into this problem fairly early in development, I figured everyone would jump up at my forum post and say "of course it's done X way, you dumbkopf", and I could facepalm at missing something so easy and get back to things...
Thanks, Bob -- that's one of my potential solutions.
It just doesn't seem like in a system which explicitly lets you chain 2 channels, and which provides a pretty sophisticated DMA system, like I should need to write an ISR just to move the results to memory -- I'd rather leave the MCU asleep and save some power, since ADC is literally 25% of my total power consumption.
I have 3 potential workarounds, including this one, but it doesn't feel like something where I should be in workaround territory...
Read the ANs, they show this (I think there might be others regarding this). Basically the DMA transfer is multi-staged. First stage is transferring the ADC results into one buffer, so each channel is one value in there. And the you have a second stage which splits these values into separate buffers (actually this is using multiple DMA transfers).
Right, I can configure this using lower level function calls. But I'm trying to build everything using the PSoC Creator 4 function blocks. So, for example, I could entirely configure DMA by hand using function calls like CyDmaTdSetConfiguration(TD_Handle,Transfer_Count,Next_TD,TD_Property), while all my other devices and ISRs are configured using the function block configurator and things like DMA channel number are automatically generated by the placer and implemented in the generated code.
But this somewhat defeats the purpose of the block diagram system -- it becomes very easy to understand the system by looking at block diagrams and the user generated code, but if I configure DMA by hand like the AN suggests, a whole section of the functionality doesn't appear in the block diagrams because it's set up using a completely different mechanism, in a different section of the code entirely.
This is actually a larger Cypress problem which I've been struggling with -- trying to avoid mixing different levels of abstraction to make basic functionality work.
It looks to me like my best option is to make a custom version of the DMA_Start() function which takes two source addresses, one for each channel. Unless someone has a better suggestion. Really, it seems to me that Creator should be automatically be detecting that I have two descriptors defined in the block diagram, and should automatically generate a version of DMA_Start() that takes two srcAddresses as input. Or even a scenario where there are two dstAddresses.
You cannot configure the DMA purely with the config dialog, you will always need to call the API for the correct setup.
But you can always open a support case with Cypress and suggest improvements to Creator, in my experience they are always eagier to get feedback.
Right. but I also can't just use the first layer of the API, the DMA_Start() function, which really should have options to set up source addresses for two descriptors when the configuration has two. Looks like i can just make my own version of DMA_start() by hand, hopefully that'll work, but I shouldn't have needed to -- Creator knows I have two descriptors. I'll suggest to Cypress and will post here if it succeeds or fails. Anyway, thanks!
Well, the component configuration screen is there for anything which gets synthesized into hardware. The API is used for anything else. Since the DMA is just a memory-transfer-device, there isn't anything special in the hardware. And no, the hardware doesn't know about your two descriptors. The connection between the DMA and the ADC is made in software.
I get that, but Creator _does_ bother to synthesize a DMA_Start() function, which I call when I initialize, but it's just one that assumes a single source address and initializes only the first descriptor, even though there are two descriptors. But I'm only getting data from only one ADC channel, so I suspect some other piece of autogenerated code is also wrong.
I'm hoping someone out there has managed to DMA from two different ADC channels using 2 descriptors?
Well, obviously I cannot speak for Cypress. I can only presume that the generated API is for the standard use-cases, and that the second descriptor is designed to be used mostly to be triggered / activated from software. And then its not a big hassle to configure it in software too. And since I see DMA mostly as something which support software by making memcpy() faster and automatic, I don't see a big problem in treating it as such. (Just as an ISR component is merely a hardware block which represent a piece of software being called automatically)
(I also need to admit that I was assuming the PSoC4 DMA works just as the PSoC5 DMA, but it doesn't. The latter is configured in software only, due to its higher flexibility).
I believe I am running into this "issue" as well. I was hoping to use the DMA to transfer 2 channels from a free running SAR component to 2 independent channels on an AC filter component, but I don't see exactly how to accomplish that. As noted by Jim, the DMA wizard doesn't offer an option to pick one or the other outputs from the SAR, though it does allow me to select the filter input stage of the appropriate channel.
I should note that I am very new to Creator and PSoC...I did not create the top design schematic, another team member did that. I imagine I may be able to make it work by reading the values out from the appropriate when the interrupt fires, and then writing them to RAM, then using the DMA to transfer that data to the filter.
Still, I agree with Jim. If other ADC components have multiple DMA selections, and the filter does as well, why not the SAR?
By the way, I am PSoC 5LP, and messing around with a CY8CKIT-050 in preparation for a development project.