- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use DMA and the SARMUX ADC. When you right-click on a component, you can select example projects. There are also example projects available when you create a new project. And there are quite a number of application notes when you search the Cypress website ('AN DMA ADC').
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes I already looked at sample codes on PSoC Creator, but nothing found with multiple ADC Channels and DMA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want a ASAP continuous scan into single memory buffer.
But I also have to calculate average values from each Channel.
Or rather, how is the best and fastest way to get average values from each of the 14 Channels?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The sequencing ADC is able to average the measurements. And: The result is stored into a result array. Read the datasheet thoroughly, it is mentioned there.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I made you said, but I get always '0' as result of all 14 Channels. So something is worng...
SDONE and DMA IRQ are running.
Is this right?
DMA_ADC_Start((void *)ADC_SAR_CHAN0_RESULT_PTR, (void *)&ADC_Buffer);
ADC is running in single channel mode, AMuxSeq seems to be switching and DMA collect 14 uint16 to ADC_Buffer[1-14]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to increase the "Heap size" (System view) to at least 0x0100 when using formatted printing!
Your project tends to get complicated, I would suggest to isolate the ADC-part into a separate project until it works, then re-integrate the code into your current project.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your help, but still not running correctly.
Now I get Data like this:
CY8CKIT-043 PSoC4-M/n/rBuffer: 0 , Data: 17521
Buffer: 1 , Data: 15981
Buffer: 2 , Data: 14157
Buffer: 3 , Data: 18007
Buffer: 4 , Data: 16156
Buffer: 5 , Data: 15624
Buffer: 6 , Data: 16310
Buffer: 7 , Data: 14206
Buffer: 8 , Data: 18214
Buffer: 9 , Data: 16411
Buffer: 10 , Data: 14038
Buffer: 11 , Data: 17985
Buffer: 12 , Data: 15869
Buffer: 13 , Data: 16015
Buffer: 0 , Data: 14119
Buffer: 1 , Data: 18150
Buffer: 2 , Data: 15870
Buffer: 3 , Data: 14438
Buffer: 4 , Data: 18121
Buffer: 5 , Data: 15961
Buffer: 6 , Data: 15557
Buffer: 7 , Data: 16260
Buffer: 8 , Data: 14071
Buffer: 9 , Data: 17834
Buffer: 10 , Data: 15897
Buffer: 11 , Data: 14843
Buffer: 12 , Data: 16744
Buffer: 13 , Data: 14654
Buffer: 0 , Data: 15909
Buffer: 1 , Data: 14260
Buffer: 2 , Data: 17770
Buffer: 3 , Data: 15995
Buffer: 4 , Data: 15928
Buffer: 5 , Data: 15842
Buffer: 6 , Data: 14103
Buffer: 7 , Data: 18311
Buffer: 8 , Data: 16293
Buffer: 9 , Data: 14493
Buffer: 10 , Data: 17594
Buffer: 11 , Data: 15450
Buffer: 12 , Data: 16397
Buffer: 13 , Data: 15920
Buffer: 0 , Data: 16877
But 4095 is the highest value at 12 Bit
And I see you disables the DMA IRQ, only for testing or does not work?
Better the DMA generates always IRQ when done, to get the newest data anytime.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The "Averaging Mode" of the ADC is set to "Accumulate" and not to "Fixed Resolution".
"I see you disabled the DMA IRQ, only for testing or does not work? " Because it is not needed at all and only consumes MIPS.
"Better the DMA generates always IRQ when done, to get the newest data anytime." There is not too much time left to spend in interrupt handlers. The project already generates an interrupt for every sample to switch the Mux, a second interrupt with the same high frequency could consume too much CPU time. On the other hand: Why are you using DMA when you want to do it using interrupts???
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK the I must all div by 16 (16 Samples averaged). But the Results are still wrong.
At the MUX0-12 is a Voltage about 1.65V +- 1mV and I testet MUX13-14 to GND (0V) but the output of all the 14 ADC always in range of 13600 to 19000 / 16 is 850 to 1187 that's are 0,68 to 0,96 mV. Far away from 1.65 or 0V???
Yes I see in your sample is the pinout differend but a few pins are correct with mine...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please show actual test project.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
??? I worked with your Sample Project, the problems come form there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My project is configured for 5V, I am using a CY8CKit-044 and did not care for the pinouts.
You do not need to divide result values by 16, use "Fixed Resolution" for ADC.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes I changed it to 3.3V and Pinout. A 0V Input must generate about 0 not bigger the 14000 something is wrong. I think the multiplexer switches not correctly...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Change line to
while(!(CyDmaGetStatus() == CYDMA_IDLE)) Wait(); // Not & but ==
You might need to insert a DMA_ADC_ChEnable(void) after validating the descriptor.
For a general test: Set the mux to a fixed channel and read out this channel only. Provide the pin with a defined voltage and compare the results.
Bob