ADC SAR data acquisition, using DMA, buffer and then transmit UART.

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.
MaBo_3742841
Level 1
Level 1
First like given Welcome!

Hi, I'm in my first post in the community.

I'm in a project where I finally want to transmit 4 analog signals via UART, now I get to the penultimate phase where I test 1 signal.

I opted to use a buffer since when sending several samples (which is my goal), when receiving in Matlab it did not arrive well.

I checked the ADC by sending to the SRAM of the PSoC and it arrives fine.

My problem specifically is at the time where the DMA to save to the SRAM of the PSoC ends and I have to activate the DMA to send via UART.

I already run out of ideas.

Regards.

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

Thank you very much.

Right now I am generating an analog signal with the same PSoC and I put the 4 inputs of the ADC SAR Seq.

Right now I write in Matlab with the following code.

hola.PNG

I'm going to take your advice and just send raw data in the smallest size possible.

I upload the project running.

Now I notice that I receive the signals with a lag of 1.5 ms (it is the same signal)

Any suggestions on how to improve that?

Regards.

View solution in original post

0 Likes
8 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Manuel,

Even though you are calling CyDmaCHEnable, a software or hardware request still must happen before the channel is executed. You can call CyDmaChSetRequest(DMA_1_Chan,CY_DMA_CPU_REQ); . Could you please confirm whether this is causing the issue at your end ?

Best Regards,
Vasanth

Thank you very much, I will try.

I tried with the NRQ of the DMA Buffer to the DRQ of the DMA Matlab.

When I sent few samples it worked fine. When it comes to increasing what is sent incorrect and different length data.

I think my mistake is in using the DMA directly to the UART register pin, I would say that due to the speed of the DMA it is much higher than that of the UART. I may be wrong.

Thank you.

Regards

Manuel.

0 Likes

You need to change the sequence of the processes.

For example:

DMA - Sends ADC data to ADC_sample buffer

ready data should be sent using the isr_DMA_Done (flag)

in the usual way without using DMA_1.

DMA_1 is not working correctly.
adc0.png

Thanks for the reply.

"Ready data should be sent via isr_DMA_Done (flag)

in the usual way without using DMA_1. "

The usual way would be with the code that is in the image?

exa.PNG

Regards.

0 Likes

It seems to me that the PSoC task is to collect and quickly transfer data, let MATLAB do all calculations / transformations.

Therefore, we just send raw data in the smallest possible size.  Even this procedure takes 3 mS.

if(DMADone_flag)

{

........

UART_PutArray((uint8*)ADC_sample ,2*ADC_SAR_Seq_NUMBER_OF_CHANNELS*NO_OF_SAMPLES);  //DMA transmission size

........

}

UART.png

An example of using the printf function:   

CE210741 UART Full Duplex and printf() Support with PSoC 3/4/5LP

lock attach
Attachments are accessible only for community members.

Thank you very much.

Right now I am generating an analog signal with the same PSoC and I put the 4 inputs of the ADC SAR Seq.

Right now I write in Matlab with the following code.

hola.PNG

I'm going to take your advice and just send raw data in the smallest size possible.

I upload the project running.

Now I notice that I receive the signals with a lag of 1.5 ms (it is the same signal)

Any suggestions on how to improve that?

Regards.

0 Likes

ADC_SAR_Seq has a multiplexer that polls channels sequentially.

Therefore, there is some delay.

This is described in ADC_SAR_SEQ_v2_10.pdf (on page 17-18)

If you need to measure all channels at the same time, you can first memorize their values using

Sample / Track and Hold Component

Further ADC_SAR_Seq will be able to digitize these values.

It seems there was such a project on the forum, but I did not find it.

0 Likes

Thank you very much.

I'm going to be reading about Sample / Track and Hold Component.

Regards.

0 Likes