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.

piccolo control stick continuous ADC makes CCS crash - why ?

I changed the continuous adc example of piccolo control stick

to adconvert only 2 inputs

the source below compiles without error but when I load and run the program

CCS crashes - why ?

==========================================

   InitAdc();  // For this example, init the ADC

// Step 5. User specific code, enable interrupts:

// Enable ADCINT1 in PIE
   PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable INT 1.1 in the PIE
   IER |= M_INT1;       // Enable CPU Interrupt 1
   EINT;                // Enable Global interrupt INTM
   ERTM;                // Enable Global realtime interrupt DBGM

   LoopCount = 0;
//   ConversionCount = 0;

// Configure ADC
 EALLOW;
 AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
 AdcRegs.INTSEL1N2.bit.INT1E     = 1; //Enabled ADCINT1
 AdcRegs.INTSEL1N2.bit.INT1CONT  = 1; //enable ADCINT1 Continuous mode
 AdcRegs.INTSEL1N2.bit.INT1SEL = 1 ; //setup EOC1 to trigger ADCINT1 to fire
 AdcRegs.ADCSOC0CTL.bit.CHSEL  = 0; //set SOC0 channel select to ADCINA0
 AdcRegs.ADCSOC1CTL.bit.CHSEL  = 1; //set SOC1 channel select to ADCINA1
// AdcRegs.ADCSOC0CTL.bit.TRIGSEL  = 5; //set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
// AdcRegs.ADCSOC1CTL.bit.TRIGSEL  = 5; //set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
 AdcRegs.ADCSOC0CTL.bit.ACQPS  = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
 AdcRegs.ADCSOC1CTL.bit.ACQPS  = 6; //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)

    AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1;  // ADCInterrupt 1 causes SOC0
    AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1;

 EDIS;

 AdcRegs.ADCSOCFRC1.bit.SOC1 = 1;   // kick start ADC by causing a SOC1 event

// Wait for ADC interrupt

   for(;;)
   {
      LoopCount++;
   AdcResults[0] = AdcResult.ADCRESULT0;
   AdcResults[1] = AdcResult.ADCRESULT1;
   AdcResults[2] = AdcResult.ADCRESULT2;
   AdcResults[3] = 0;      // ADC-A6 NOT AVAILABLE on controlSTICK
   AdcResults[4] = AdcResult.ADCRESULT4;
   AdcResults[5] = 0;      // ADC-A5 DOES NOT EXIST
   AdcResults[6] = 0;      // ADC-A6 NOT AVAILABLE on controlSTICK
   AdcResults[7] = AdcResult.ADCRESULT7;
   AdcResults[8] = 0;      // ADC-B0 DOES NOT EXIST
   AdcResults[9] = AdcResult.ADCRESULT9;
   AdcResults[10] = AdcResult.ADCRESULT10;
   AdcResults[11] = AdcResult.ADCRESULT11;
   AdcResults[12] = AdcResult.ADCRESULT12;
   AdcResults[13] = 0;      // ADC-B5 DOES NOT EXIST
   AdcResults[14] = AdcResult.ADCRESULT14;
   AdcResults[15] = AdcResult.ADCRESULT15;

   }

}

  • No body replied to my question     :-(

    thats why I tried to fix my code on my own

    I added the below ISR and problem disappeared

    now I can adconvert only 2 analog inputs

    I wonder why on contiunous_ADC example of picclo control stick there was no adc_ISR ? It misleaded me

    ==============0===============

    interrupt void  adc_isr(void)
    {

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

      return;
    }

    ==============0===============

    2 ) I observed that there were very much jitter in ADC results - the measurement played +/- 30

    how can I get a clean conversion on analog input ?

     

  • Hello,

    First Post:

    What is meant by CCS crashes?  If you try the ADCContinuous example directly without changing the code does the software work?

    Without doing a full review of your code I would try changing: AdcRegs.INTSEL1N2.bit.INT1SEL = 0 ;

    ----
    Second Post:

    1)  I am glad you were able to get the code working. In the continuous ADC example setting the ADC.  The INTxCONT bit should auto-clear the adcint flag if it is used correctly.

    2) Jitter on the ADC is largely because the board is an evaluation board and therefore does not use a full set of noise suppression techniques (isolated analog and digital sections, etc)  Also, your noise may be noise from the signal itself. To measure noise on an ADC you could sample a 1.8V battery and measure the ADC noise exactly.


    Thank you and best of luck in your project,
    Brett