Streaming From DelSig to USB using DMA

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

cross mob
lock attach
Attachments are accessible only for community members.
psoc_5lp_life
Level 1
Level 1
First reply posted First question asked Welcome!

Problem Statement: I would like to sample an analog pin on the CY8CKIT-059 PSoC 5LP Prototyping kit using the DelSig component with a sample rate of 46875 Hz and a resolution of 16-bit and stream this data out without any loss through USB to a computer host continuously.

 

What I have tried that Works: I can chain 14 TDs, each having a 4094 byte DMA transfer (i.e. 4094/2=2047 16-bit samples), disable the DMA at the end of all 14 TDs and then transfer using USB max packet size of 64 bytes at a time and receive it using the USB Control Center application. The 100Hz square wave from the function generator looks perfect.

 

What I have tried that does not work (Goal): Ping Pong DMA with 64 byte transfers for two DMA TDs and USB transfers.

 

OS: Windows 10 x64

USB Driver: cyusb3.sys (unmodified from EZ-USB FX3 SDK)

Using 24MHz PLL setting in Clocks.

USB Transfer Type: Bulk Transfers

USB Buffer: DMA with Manual Buffer Management (Static Allocation)

DelSig Conversion Mode: 2- Continuous

DelSig Alignment: Left, 16 bits (Not OVF Protected)

DelSig using internal sampling clock with auto calculated 3072 Hz frequency

 

I have used the ping-pong DMA approach from this example. I replaced the WaveDac8 in the Data Acquisition project with a real signal from a function generator producing 1V 100 Hz Square Wave. The resulting samples from using the "USB Control Center" utility part of the latest EZ-USB FX3 SDK (requesting say 8192 samples) look completely distorted and look like they are missing samples. 

https://community.cypress.com/t5/PSoC-5-3-1-MCU/Continuous-sampling-and-data-transfer-using-DMA-and-...

0 Likes
1 Solution
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi @psoc_5lp_life ,

I went through both the attached projects. The configuration of the DMA in the  Data Acquisition project seems to be correct.

On comparing both the projects I found that in the project where you are using 14 TDs there is a DMADone_flag that is set to one when a DMA transfer occurs. The data from the SRAM buffer is written to the USB Endpoint only when this flag is set. But in the case of 2 TDs there is no such flag or check. Therefore there might be a possibility that same Data from the SRAM buffer is copied multiple times to the USB Endpoint.

Can you try using a similar flag in the second project also?

You can also try debugging the project and keep a watch on the data that is every time being copied from the SRAM buffer to the USB Endpoint. Also check if it matches with the value of data.val1.bufferMem16[] and data.val1.bufferUSB16[]

Let me know if this helps.

Thanks and Regards

Ekta

View solution in original post

0 Likes
3 Replies
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi @psoc_5lp_life ,

I went through both the attached projects. The configuration of the DMA in the  Data Acquisition project seems to be correct.

On comparing both the projects I found that in the project where you are using 14 TDs there is a DMADone_flag that is set to one when a DMA transfer occurs. The data from the SRAM buffer is written to the USB Endpoint only when this flag is set. But in the case of 2 TDs there is no such flag or check. Therefore there might be a possibility that same Data from the SRAM buffer is copied multiple times to the USB Endpoint.

Can you try using a similar flag in the second project also?

You can also try debugging the project and keep a watch on the data that is every time being copied from the SRAM buffer to the USB Endpoint. Also check if it matches with the value of data.val1.bufferMem16[] and data.val1.bufferUSB16[]

Let me know if this helps.

Thanks and Regards

Ekta

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

Ekta, thank you for getting back to me so quickly! You are a life saver.

I have attached a version of the continuous PingPong DMA project with the DMADone flag. Using the USB Control Center with PktMode checkbox selected and say transferring the bytes to transfer as 64000 results in a timeout. Is there anything we could do also to increase the Bulk Transfer timeout to make it just like infinite?

0 Likes

Actually, it works now with the project above! I can't believe it!

 

Is it better to receive 64 bytes at a time or is it better to receive bigger chunks of data, say for the purpose of real-time plotting.

0 Likes