You are here

How to access ADC data faster. | Cypress Semiconductor

How to access ADC data faster.

Summary: 22 Replies, Latest post by muhammad.yaqoob_1490236 on 17 Nov 2016 08:47 AM PST
Verified Answers: 1
Last post
Log in to post new comments.
muhammad.yaqoob_1490236's picture
User
53 posts

Dear All,

Is there a way to access ADC data faster than the command given below:?

vol= ADC_SAR_CountsTo_Volts(ADC_SAR_GetResult16());

It costing around 10 us at least to get value in vol. Even though I am getting 1 Msps which can be seen via eoc pin.

user_1377889's picture
User
9596 posts

It depends on what you want to perform. Collecting data with 1 Msps is one thing, question is: How many items and how often and what to do with the results. Can you be a bit more specific about your complete project or are you just searching for the limits?

One way out is DMA or directly accessing the ADC results which are stored in an array.

 

Bob

muhammad.yaqoob_1490236's picture
User
53 posts

Thanks for quick response.
I am trying to implement a digital PI controller for a DC-DC converter. The switching frequency of the converter is 100 kHz (10 us). SOC pin is connected to the rising edge of the PWM and at EOC (@ 1 Msps) an ISR is initiated to load value via the command that I wrote in my first comment followed by 3-4 multiplications related to PI variables. I want ISR to finish these tasks before next cycle of PWM but only fetching a value from ADC is consuming time more than PWM period i.e., 10 us.  

user_1377889's picture
User
9596 posts

The ADC_SAR_CountsTo_Volts() API uses a calculation as y= ax +b which you may omit in your own calculations. ISR call consumes some time as well, saving the registers and changing the context is not done in zero time. Polling may be faster.

The GCC is so "smart" that just setting a flag in an interrupt handler (no multiplication!!) is quite a lot faster, because only a few registers are needed to be saved.

Put your code in a separate file and after testing set the optimization for this file to "speed" which will keep the rest of the project still debuggable.

 

Bob

muhammad.yaqoob_1490236's picture
User
53 posts

What if I want to access that array containing ADC's values that you talked about in your first reply? 

 

user_1377889's picture
User
9596 posts

Look into the ADC_SAR_Seq_finalArray in the .h file (Near line 33)

 

Bob

muhammad.yaqoob_1490236's picture
User
53 posts

but how to access it into main.c and in to the ISR initiated by EOC of ADC?

muhammad.yaqoob_1490236's picture
User
53 posts

A reference to a document and project would be appreciated . 

user_1377889's picture
User
9596 posts

ADC_SEQ_Sar datasheet tells about DMA filling the array at end of conversion. Array declaration is (already!) included in .h file, so you can access the array directly from main(). Channel 0 is element 0 and so on...

 

Bob

muhammad.yaqoob_1490236's picture
User
53 posts

Undefined Reference!

user_1377889's picture
User
9596 posts

So you are not using the sequenced ADC.

 (int16) CY_GET_REG16(ADC_SAR_1_SAR_WRK_PTR);

 

Bob

Log in to post new comments.