This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hi,
I am using ADC interrupt to store the input result from pin A0 and A1 in variables i and j from adcResult0 and adcResult1. Now i need to gate the value with 250 samples delay, how to obtain this.
I am using 28379D controller.
Do you want the first 250 samples to be discarded? If so, you can just assign a dummy array as follows:
int resultsIndex = 0;
:
:
:
if(resultsIndex<250))
{
dummy[resultsIndex] = AdcaResultRegs.ADCRESULT0;
dummy[resultsIndex++] = AdcaResultRegs.ADCRESULT1;
AdcaRegs.ADCINTFLGCKR.bit.ADCINT1 = 1; // clear the interrupt - example assumes you are using ADCINT1
}
else
{
I = AdcaResultRegs.ADCRESULT0;
j = AdcaResultRegs.ADCRESULT1;
AdcaRegs.ADCINTFLGCKR.bit.ADCINT1 = 1; // clear the interrupt - example assumes you are using ADCINT1
}
:
:
:
Regards,
Joseph
thank you Mr. Joseph,for your reply.
Perhaps i was not clear enouph from my previous mail.let me ellaborate it clearly.
I have an incoming sinewave of 20ms period, which i detect and read it by using ADC interrupt at pin A0.Now i need to shift it by 90 degree.Here i need to calculate the samples per 360 degree, then for 90 degree so that i can shift the result of previous variable.But, i don't know at which frequency sampleing occurs.If i write a loop inside ADC interrupt then the loop speed and the interrupt sampling speed would be different. Because ADC isr depends upon the EPWM period,which is at 2kHz.I think it will cause a sampling mismatch.So my questions are
1- How to know the sampling frequency at which ADC_isr samples the input pin, does it depend upon PRESCALE register value or the speed at which interrupt configures.
2-To provide phase shifting, whether the sampling delay approach is good enough.
3-Does the speed of ADC_interrupt and a loop for storing some value inside interrupt routine should be similar, if so how to provide this.
In a briefnote,i am storing the input sine value in a variable as 'i'.Now i need 'i1', which exactly runs 90 degree away.
Kindly suggest me any suitable method by providing some example.
Thank you for your attention.
You are partially correct. i am not using any feedback loop here, neither i intend to adjust the source. I obtain the result of sinewave at every sampling instant with a variable name as 'v'. Now i want to generate another set of samples to be stored in a variable 'v1', which is with some samples delay, lets say 250 samples. these 250 samples surely indicate some angle wrt the source wave and i want this angle should be 90 degree.So by any means, if i know the number of samples in 20 ms (related to 50 Hz frequency of sine wave), then i can calculate it for 90 degree.
Kindly verify the attached document, which indicates two sine wave.I am able to obtain the first one in one of the ADC pin and i need to obtain the second.So
please help how to write the programme, whether it should be placed in _isr or in the main programme.