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.

CCS/TMS320F28379D: 28379D

Part Number: TMS320F28379D

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.

  • Hi D Mishra,

    Sorry, I am not completely understanding how you intended to use the ADC conversions for phase shifting. Based from the information you sent, I believe you wanted to capture the sinewave and decide when to shift the source by 90 degrees. Seems to me like you wanted to dynamically determine the start of the sinewave and through feedback loop, adjust your source accordingly? Is my understanding correct?

    Best regards,
    Joseph
  •  Hi Joseph for your reply.

    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.

  • Hi D Mishra,

    Thanks for the additional details. My suggestion is to store the contents of the full sinewave in an array first (array v )then determine the count (n) for the 90 degrees point. On successive iterations store captured data as array v[i] and another set of data with the adjusted position say array v1[i-n]. If you use ePWM as trigger, the sampling rate will be fixed so you can petty much have a fixed offset for the 90 degree point, but to make sure that this will work, the sinewave source should be coherent with your sampling otherwise the counting will be off after some time.

    You would want to place this in your main code, not in the ISR as the added instructions (e.g.-storing in array and deciding if it is the 90degree point) will make the cycle counts in the ISR non uniform for every conversion and will cause the sampling rate to be off as well.

    Hope this will give you an idea on how to carry out this task.

    Regards,
    Joseph
  • Hi D Mishra,

    Not sure if you were able to resolve your issue of phase shifting the converted values to 90 degrees using the suggestions above. I'm closing this thread for now but if you still have questions with the suggested scheme, please feel free to post it in this forum.

    Best regards,
    Joseph
  • Thank you for your response.