Continuous sampling and data transfer using DMA and USBFS

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello everyone,

I started this discussion because I have a question regarding the timings between:

- ADC to memory, using DMA;

- PSoC to computer using USBFS.

The way I want to approach this is: (using 100 2-bytes samples as an example)

1 - ADC sample to memory1, using DMA

2 - Copy those samples from memory1 to memory2

3 - ADC sample to memory1, using DMA & USBFS transfers from memory2 to PC

4 - repeat step 2 to 4 until desired number of samples is acquired.

Is this possible with the PSoC?

I'm struggling with:

- is the process of copying memory1 to memory2 fast enough that I don't loose data?

- how can I pause the DMA for the copy from memory1 to memory2 to happen?

Thank you for your help

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

i didn't put the condition to limit the number of samples, because I simply want to send using the ping-pong methodology, so I'll attach my project so that it's easy to see what I've done.

View solution in original post

0 Likes
12 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

What ADC sampling frequency is required?

/odissey1

0 Likes
Anonymous
Not applicable

Now I'm using a sampling frequency of 25kSPS

0 Likes

TelmoBarros,

How you plan to transmit the data (bulk transfer mode, or USBUART-type)? What SW on the PC side you are going to use? What ADC type (DelSig or SAR)?

take a look at this post, maybe it already answers your needs

How to configure USBFS in audio IN mode with DMA automatic buffer management ?

0 Likes
Anonymous
Not applicable

At the moment, I'm transmiting the data in Bulk transfer mode.

On the PC side, I'm working with Python to receive the data and perform further analysis.

The ADC that I'm using is DelSig.

I just want to be able to send, for example, 50k samples. The previous way I implemented, does not allow this. Firstly, I stored the Samples on the PSoC, and only after completing the conversion process, I would send all of them by Bulk transfer mode

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received
0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

After re-reading the DMA datasheet, I'm sure that I want to implement something similar to the Ping Pong project.

I want to implement it with the USBFS componen.

So, when one array is being filled by the DMA, the data on the other one is being transmitted by the USBFS component.

I think it's not working because the DMA is too fast filling and changing from one buffer to the other.

I attached the project to this post.

0 Likes
lock attach
Attachments are accessible only for community members.

Try replacing the ADC with ADC_SAR and reducing the sampling rate of the ADC.

My project is redone under the CDC and I do not exceed 200 kSPS.
200ksps_.PNG

0 Likes
Anonymous
Not applicable

Why do you choose ADC_SAR over ADC_DelSig?

I'm going to check your project now, but I just want to know why is it important

0 Likes

ADC_DelSig allows no more than 48000 SPS

0 Likes
Anonymous
Not applicable

I see.

What I want to be ale to do is to overcome that limit. I'd like to have, for example 200 000 samples.

I chose the ping-pong DMA implementation, but i'm not sure how to check if the program is succesful

- while dma is filling slot of memory 1, the usbfs component should access the slot of memory 2

- after they finish, they should change and keep going until I meet the number of samples I want

0 Likes

There may be enough counter:

cnt = 200000/64

decrement=1;// start

....

if(Cnt) { USBFS_LoadInEP(USBFS_cdc_data_in_ep, pUSB, 64); cnt=cnt-decrement;}

else decrement=0;// stop

....

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

i didn't put the condition to limit the number of samples, because I simply want to send using the ping-pong methodology, so I'll attach my project so that it's easy to see what I've done.

0 Likes