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/TMS320F28027: About ADC Configuration

Part Number: TMS320F28027


Tool/software: Code Composer Studio

Hello ,

I am a newbie to microcontrollers. I started learning about ADC configuration from example "adc_soc". I didn't understand the following. please help

/ Wait for ADC interrupt
   for(;;)
   {
      LoopCount++;
   }
}

why LoopCount++ loop is required?

__interrupt void adc_isr(void)
{
  Voltage1[ConversionCount] = AdcResult.ADCRESULT1;  //discard ADCRESULT0 as part of the workaround to the 1st sample errata for rev0
  Voltage2[ConversionCount] = AdcResult.ADCRESULT2;

  // If 20 conversions have been logged, start over
  if(ConversionCount == 9)
  {
     ConversionCount = 0;
  }
  else
  {
      ConversionCount++;
  }

  AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;  //Clear ADCINT1 flag reinitialize for next SOC
  PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;   // Acknowledge interrupt to PIE

  return;
}

I have understood that adc_isr function is called in the " PieVectTable.ADCINT1 = &adc_isr;"

but what is the fuction of it and how come the loop is continuing?

  • Hi Madhuri,

    Madhuri Depuru said:
    why LoopCount++ loop is required?

    No specific reason but to simply count the total code cycle counts.

    Madhuri Depuru said:

    I have understood that adc_isr function is called in the " PieVectTable.ADCINT1 = &adc_isr;"

    but what is the fuction of it and how come the loop is continuing?

    The above is to map the ADC ISR to the ADC Interrupt in vector table.

    Let me know if you still have any doubts.

    Regards,

    Gautam

  • Hello, Madhuri.

    About your questions:

    Madhuri Depuru said:
    why LoopCount++ loop is required?

    "LoopCount++" is not really needed. It's just a counter, that you can check to insure, that your MCU is working fine. You can safely delete this line.

    Madhuri Depuru said:

    I have understood that adc_isr function is called in the " PieVectTable.ADCINT1 = &adc_isr;"

    but what is the fuction of it and how come the loop is continuing?

    It's not called in that line. This procedure is and ISR. That means, that this procedure will be called, when a particular INTERRUPT will be triggered. In your case this interrupt is "ADCINT1". The line " PieVectTable.ADCINT1 = &adc_isr;" means "when ADCINT1 interrupt will be triggered, call function with name "adc_isr"".

    So, your loop will be calculated, until the ADCINT1 interrupt occurs. Than your loop stops, "adc_isr" is calculated, and then you loop is continued.

    I strongly recommend you to spend time for examining some workshops, like this:

    Also you can check wiki - there are example projects and trainings:  

    I think these recources can help to cover lots of questions, that C2000 neophyte can have.

  • Thank you Gautam & Disona

    your replies are really helpful

  • You're Welcome Madhuri!

    Goodluck & Regards,
    Gautam