Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > ADCINCVR

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



ADCINCVR
Moderator:
RKRM

Post Reply
Follow this topic



ADCINCVR

yellowcreak posted on 04 Feb 2010 10:51 PM PST
Senior Member
14 Forum Posts
Hi,
Does anyone knows how does the calculation of the ClacTime(equation 9) in the datasheet of the ADCINCVR (Pg4 of 28) works?

The datasheet states that the CalcTime is equivalent to 180 CPU cycles and must be express in terms of dataclock.
I assume if my CPU_Clock is SysClk/8=24Mhz/8=3Mhz,
my DataClock=VC1=SysCLK/N=24Mhz/12=2Mhz, does that mean that
the CalcTime =[180*/(3Mhz)]*2Mhz = 120 DataClock cycles.

Does the DataClock mention in the datasheet mean VC1,VC2 and VC3 which you chose to clock the ADCINCVR?

What units are the terms in equation 8 using?
Sampling Rate=hz?
DataClock=hz or seconds?
CalcTime=seconds or Dataclock cycles?

Please help


Re: ADCINCVR

graa posted on 04 Feb 2010 02:34 PM PST
Cypress Employee
275 Forum Posts
Yes. Your understanding of the CalcTime equation is correct. For a CPU clock of 3MHz and DataClock of 2MHz, the CalcTime is 120.

The units are:
Sampling Rate = Samples Per Second
Data Clock = Hz
CalcTime = No. of Data Clocks

Re: ADCINCVR

yellowcreak posted on 05 Feb 2010 05:23 AM PST
Senior Member
14 Forum Posts
Hi Ganesh,
Thanks for the confirmation.

Another thing about ADCINCVR....
Can the ADC work without using the ADCINCVR_GetSample API?
When the ADCINCVR_GetSample API is in use, the global interrupt is uitilise.
If a DAC incorprated in the microprocessor also uses the globel interrupt to execute a ISR, will the ADC trigger the ISR also via the ADCINCVR_GetSample API?

Re: ADCINCVR

yellowcreak posted on 06 Feb 2010 12:15 AM PST
Senior Member
14 Forum Posts
Hi Ganesh,

Is there another way to connect the package input to the ADCINCVR input?

If I'm using a REFMUX to get port[0]7 to input to the ADCINCVR input, what do i configure for the REF input of the REFMUX?

If i'm using a DAC and the ADCINCVR at the same time, do i configure both UM's IntDispatchMode to "OffsetPreCalc"?

Re: ADCINCVR

graa posted on 08 Feb 2010 04:09 AM PST
Cypress Employee
275 Forum Posts
Yes. You can only get the ADC to sample using the ADC_GetSamples function. Also, the ADC conversion involves some interrupt processing when reading the ADC results. The DAC does not use any interrupts.

You can connect some of the Port2 pins directly to the ADC without having to go through the CT blocks. Depending on the SC block where you place your ADC, the direct Port2 connection varies. You can check the availability of the Port2 pin by clicking on the Input parameter of the ADC.

The InitDispatchMode parameter only applies to dynamic reconfiguration. If you are not using dynamic reconfiguration, then this parameter has no relevance to the ADC.

Re: ADCINCVR

yellowcreak posted on 08 Feb 2010 04:34 PM PST
Senior Member
14 Forum Posts
Hi Ganesh!
Thank you for the reply.

Maybe i should give more information about the DAC.
I've been working on the DAC to produce the sinewave from the example project recommanded from the previous tread "Sinewave generator".

The example project seems to use the 16BIT Counter to generate a global interrupt to trigger the ISR where instructions for the DAC to pick the relevant value from the lookup table and output the value resides.

If I'm to add in the ADCINCVR into the project, will the UM blocks from the ADCINCVR and the 16BIT Counter for the DAC effect each other's operation via the Global interrupt?

If a zero value is used in the ADC_GetSample function the ADC will get samples continueously. What will other value useds in the function prompt the function to do?

Last question...What value is to put in the CalcTime parameter for the ADCINCVR?
Isn't the CalcTime parameter for the ADCINCVR approximately 180 CPU cycles?
Must I convert the the 180 CPU cycles to Dataclock Cycles and input the parameter as DataClk cycles?

Re: ADCINCVR

graa posted on 08 Feb 2010 06:24 PM PST
Cypress Employee
275 Forum Posts
If you set the CalcTime parameter right, the interrupt of the Timer will not affect the ADC. The CalcTime parameter is the number of data clocks that the ADC will hold the result for the processor even if the processor is busy with some ISR. The number 180 used in the equation is the number of CPU cycles taken by the ADC's ISR to read the ADC result. If you add the number of clock cycles used by the Timer's ISR, then even if the Timer's Interrupt triggers just before ADC's interrupt, the ADC result will not corrupt till the Timer ISR and the ADC ISR are executed. So, for example, if your timer ISR takes 170 CPU cycles to execute, then use the value 350 (180 + 170) in the CalcTime equation.

On the other hand, when the Timer Interrupt occurs, if the processor is busy with the ADC's interrupt, then the Timer's interrupt will be serviced only after the ADC's interrupt is completed. So, this will result in some interrupt latency which may reflect on the output sine wave. The worst case interrupt latency would be 180 CPU cycles. Place the Timer in a higher row than the ADC's digital blocks. This will place the Timer in a higher interrupt priority and will ensure that the Timer ISR executes first when both ADC and Timer interrupts are pending.

Re: ADCINCVR

yellowcreak posted on 21 Feb 2010 07:42 PM PST
Senior Member
14 Forum Posts
Hi Ganesh,
How do I determine the numbers of CPU cycles the Timer ISR take so as to add the value with the ADC 180CPU cycles?

Anyway I've written the ADC part of the program as:

int iData;
void main(void)
{
.
.
.
while(1)
{
if (ADCINCVR_1_fIsDataAvailable() != 0)
{
iData = ADCINCVR_1_iGetData();
ADCINCVR_1_ClearFlag();
if(iData < 140)
{........}
else
{........}
}
}
}

The ADCINCVR Dataformat is set to unsigned.
I've also set the ADCINCVR Calc Time to 248.
Is there a problem with the program i've written or the settings I've done?

Re: ADCINCVR

graa posted on 22 Feb 2010 06:49 AM PST
Cypress Employee
275 Forum Posts
Hi Yellow,
If you have written the Timer ISR in C, you will have to open the .lst file and manually add the CPU cycles for all the instructions in the function. Check the Assembly Language User Guide (from Help >> Documentation menu) for details of CPU cycles of different instructions.

Re: ADCINCVR

yellowcreak posted on 22 Feb 2010 09:28 PM PST
Senior Member
14 Forum Posts
Hi Ganesh!
Thank you for the info.
I'm still facing some problems with the ADCINCVR.
It seems not to be processing any data.
I hope that I've provided enough information for a discussion.

Global Resources
PowerSetting[Vcc/SysCLK]~5V/24MHz
VC1 = SysVlk/N~12
Ref Mux~P2[4]+/-P2[6]
The rest are as default

Here are the properties settings of the ADCINCVR I've set:
Input~Port2_2
ClockPhase~Swap
Clock~VC1(Which is 2Mhz)
ADCResolution~8
CalcTime~520
DataFormat~Unsigned
IntDispatchMode~ActiveStatus

For the Digital Block placements, I've placed the DAC Counter at DBB00 & 01, the ADCINCVR CNT at DCB12 and the ADCINCVR PWM at DBB20 & 21. All Digital blocks clock are from VC1(2Mhz). The DAC counter will generate a global interrupt in 266hz to trigger the DACs to output.

For the Analog blocks placements the ADC is placed at ASD13 and input from PORT2_2. I've one set of DAC8 placed at ASC10 and ASD20, Analogbus to Buf 0 then to Port_0_3. Then I've another set of DAC8 placed at ASC11 and ASD21, Analogbus to Buf 1 then to Port_0_3.

The C programming I've written is as follows:
BYTE Pointer;
int iData;

void main(void)
{ M8C_EnableGInt;
Counter16_1_Start();
Counter16_1_EnableInt();
DAC8_1_Start(DAC8_1_HIGHPOWER);
DAC8_2_Start(DAC8_2_HIGHPOWER);
ADCINCVR_1_Start(ADCINCVR_1_HIGHPOWER);
ADCINCVR_1_GetSamples(0);

While(1)
{
if (ADCINCVR_1_fIsDataAvailable() != 0)
{
iData = ADCINCVR_1_iGetData();
ADCINCVR_1_ClearFlag();
DAC8_1_Start(DAC8_1_LOWPOWER);
DAC8_2_Start(DAC8_2_LOWPOWER);
}
}
}

#pragma interrupt_handler Counter_ISR;
void Counter_ISR(void)
{
DAC8_1_WriteBlind (SineTable1[Pointer]);
DAC8_2_WriteBlind (SineTable2[Pointer]);
Pointer++;
if(Pointer >= 64)
{Pointer = 0}
}

Sinetable1 and SineTable2 are 64 Points lookup tables stored in ROM.
When i powered up the CY8C29466, the output gives a highpower signal instead of a lowpower signal.
If the ADC is reading and processing signal a lowpower signal should be observed.
Any comments from anyone?

Re: ADCINCVR

yellowcreak posted on 22 Feb 2010 09:31 PM PST
Senior Member
14 Forum Posts
Sorry...I left out one data CPU_Clock~SysCLK/8

ADCINCVR 'data available' api indicates no data...

DJRegan posted on 23 Jul 2011 09:49 PM PST

1 Forum Post

Regarding use of ADCINCVR and its API 'ADCINCVR_1_fIsDataAvailable' ...

Is there a known list of reasons why the ADCINCVR user module would never provide an indication for data being available?

Reason I ask is when I comment out the following line of code...

//if (ADCINCVR_1_
if (ADCINCVR_1_fIsDataAvailable() != 0) () != 0)

...and I therefore allow unconditional entry into the block of code that includes getting the A/D sample and clearing the flag, everything appears to work great. I can tell valid a/d readings are able to be acquired from the ADCINCVR user module.

However, when I uncomment the above line of code that checks for data availability, l can never acquire an A/D reading.

 

What are the known reasons that API *fIsDataAvailable() will always return 'no data available'?

Thanks much in advance,

--DJR






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20