- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I’m trying to transfer data from ADC-SAR to UART using the DMA. For this I followed the Configuration showed in AN52705, but I’ve got this error:
“.\main.c: In function 'DMA_Config':
.\main.c:83:36: error: 'ADC_SAR_1_WRK0_PTR' undeclared (first use in this function)”
Could anyone help me?
Best regards
Hosam
Main + DMA configuration:
#include <project.h>
/* DMA Configuration constants for DMA_1 */
#define DMA_1_BYTES_PER_BURST (1u)
#define DMA_1_REQUEST_PER_BURST (1u)
#define DMA_1_SRC_BASE (CYDEV_PERIPH_BASE)
#define DMA_1_DST_BASE (CYDEV_PERIPH_BASE)
void DMA_Config(void);
int main()
{
ADC_SAR_1_Start();
DMA_Config();
ADC_SAR_1_StartConvert();
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
/* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
for(;;)
{
/* Place your application code here. */
}
}
void DMA_Config()
{
/* Variable declarations for DMA_1 */
uint8 DMA_1_Chan;
uint8 DMA_1_TD[1] = {0};
/* Iniitialize DMA channel */
DMA_1_Chan = DMA_1_DmaInitialize(DMA_1_BYTES_PER_BURST, DMA_1_REQUEST_PER_BURST,
HI16(DMA_1_SRC_BASE), HI16(DMA_1_DST_BASE));
/* Allocate TD */
DMA_1_TD[0] = CyDmaTdAllocate();
/* TD configuration setting */
CyDmaTdSetConfiguration(DMA_1_TD[0], 1u, DMA_INVALID_TD, DMA_1__TD_TERMOUT_EN);
/* Set Source and Destination address */
CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint16)ADC_SAR_1_WRK0_PTR), LO16((uint16)UART_TXDATA_REG));
/* TD initialization */
CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);
/* Enable the DMA channel */
CyDmaChEnable(DMA_1_Chan, 1u);
}
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is always advisable to post the complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file (do NOT use chrome, that still may not work).
Probably you have made a typo regarding your Component's name.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe datasheet is in error becuse in its table definition vs example furthere on in
datasheet there is this typing -
result = CY_GET_REG16( ADC_SAR_1_SAR_WRK0_PTR );
Regards, Dana.
- 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 Dana for your hint, its working know 🙂
i just posted the Project before I read your reply
thank you Bob too
Hosam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
here I’m again,
after successful compiling I implemented the Project on CY8KIT-001(PSoC 5LP), unfortunately I couldn’t get any data throw the UART-port when using the DMA.
I just tested the communication throw UART by sending the ADC-data without DMA und it works.
Could someone take a look at it, that would be nice?
Best regards
Hosam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to use the DMA wizard as described here (Page 32)but the UART didn’t appear in the “Destination” field. Maybe I have to activate the UART to be reached by DMA ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In CyDmaTdSetConfiguration() you specified DMA_INVALID_TD as the next TD, I think you should use the TD[0] to transfer multiple bytes and not only one. Additionally i would set SAR-bits to 8.
You will get a maximum of about 10000 bytes/second over the UART line, but the SAR delivers more samples, you must find a solution for that problem.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Bob, I’ll try it on Monday and give a feedback
Actually, for further processing on a PC I want to transfer the data with up to 400KSps. But I think it’ll not work as I wish. So i’ll try to implement the data processing on chip, eg. FFT or maybe use another interface.
I’m a beginner in PSOC and this project becomes complicated but still interesting 🙂
Hosam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You m ight want to file a CASE to solve this using full res of
SAR. Looking at forum no one seems to have done this yet.
And post back the solution for others.
To create a technical case at Cypress -
“Support”
“Technical Support”
“Create a Case”
You have to be registered on Cypress web site first.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It still doesn’t work…
I could read the nrq-Signal of the DMA with a oscilloscope out, it is pulses with the frequency of 857143Hz which is the Sample rate of the ADC, that means, the samples are written in the memory (register of UART) but not transferred out.
I found this on PsocDevelopper, it seems to be a similar problem like mine but somehow I couldn’t open the zip-file. Besides is it you Bob and Dana in this conversation?
Regards
Hosam
Ps. I filed a case about “Transmit High-Rate ADC_Samples through UART” and soon I’ll post the/a solution
- 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
Maybe I should reread thread, but looking at latest posted
project -
1) Your ADC is set for 1M SPS, 8 bits, so thats 8 Mbyte/sec or
8 Mbits/sec, + some overhead for EOC and read and DMA.
2) Your UART is set to 115K bits/sec, or ~ 14 Kbytes/sec.
In short you are producing far more data that the UART can handle.
Try reversing the rates, eg slow SAR down to its min of 74 K SPS or use
a trigger for conversion, to get rate down << UART, and thens ee if data
stream starts making sense. Or average enough samples to get rate <<
UART.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Correct this -
1) Your ADC is set for 1M SPS, 8 bits, so thats 8 Mbyte/sec or
8 Mbits/sec, + some overhead for EOC and read and DMA.
to this -
1) Your ADC is set for 1M SPS, 8 bits, so thats 1 Mbyte/sec or
8 Mbits/sec, + some overhead for EOC and read and DMA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hosam,
You have different choices based on your environment or your needs:
You may sample data with a high rate for a short time, buffer the data and then transmit the chunk over the UART.
You may setup a timer at 400kHz, set your SAR for single conversion and trigger each conversion. At eoc get and transmit the result. This method can come near the availlable MIPs of the core, so using DMA will free some of the needed instructions.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
That’s exactly what I did today. Fist suggestion
- Sampling with “Actual conv, rate (SPS) = 666667”, so I’m expecting 666667 sample/s
- Use the ADC_SAR_IRQ the buffer 40 samples und then stop the interrupt
- Transfer them via URAT
The signal on Pin_2 is pulses with the frequency 666667 Hz, so far so good, cause I’m sampling with 666667 sample/s
so now, how could I check, that every sample has been transferred without losing any of them, in other words, dose the interrupt routine as fast as the sample rate?
I did this:
(666667 sample/s)/ 40 samples = 16666,675 1/s
If I had an input signal with frequency of 16666,675 Hz, the 40 samples should represent one period, but instead I get two periods -> the interrupt routine is as half fast as the sample rate
Why???
How could I buffer high sample rate data in a variable?
Hosam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since you are using the CPU to transfer the data from ADC to RAM you should increase the CPU clock. First try should be 48MHz and an adaption of the ADC sps to 666666.
To get more headroom, I would suggest you to have a look (and get acquainted to) DMA. There is an ADC / DMA example.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I cannot find your interrupt routine for your ADC. A good practice is to use
CY_ISR_PROTO(), CY_ISR(), an isr component connected to eoc and isr_StartEx().
The first two are documented in "System Reference Gude" to be found from Creator's Help-menu.
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
In workspace explorer, there is a file close to top, suffix *.cydwr, double
click that and then pick clocks tab, then edit clock.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the intrerrupt routine, have a ptr to an array[ 40 ], inc the ptr, store the sample.
Then test if ptr == 39, if so make it 0 to point at beginning of array for the next
buffer fill. Also if it is 39, UART the data out.
Declare the array and ptr as volatile.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Open the .cdwr file and click on the "Clocks" tab, then double-click on any system clock.
BTW: you should update your Creator to latest version, use the update manager
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I’ll give an update tomorrow
Hosam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
sorry for the delay.
Hier ist my latest project regarding sampling und buffering with high sample rate.
It samples und buffers the values with ca. 600 ksps then calculate the 128-points-DFT und send the result via UART to the PC.
I thoght it could be helpful for other members
Best regards
Hosam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Hosam,
As I am unable to open the "TopDesign" because of 2.2 version so can you upload the snapshot of the TopDesign and configuration setting of ADC and UART?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Nisargshah
What do you think about upgrading your Cypress Creator to version 3.0? There are new devices, new components and some errors corrected.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is not possible at this moment.. Later on it may possible.. but currently I have to use this..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Creator 2.2 and Creator 3.0 are co-existent. You may download and install 3.0, open the project and copy the settings and code with cut&paste to your 2.2 project.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But this is not possible.. If some can take the snapshot of this then it will be ok for me.