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.

ADC - noncontinuous conversion

Hi

I want to use a noncontinuous conversion. But can someone please help me. With noncontinuous mode you have to clear the ADCINTFLG manually. But why when i set the

 " AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC " bit it doesnt work.

 

I got the contiuous mode working perfectly but i need noncontinuous. Here is my ADC init code:

 

// ADC INITIALISATION

    EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Use internal bandgap

   AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power up band gap

   AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power up reference

   AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power up rest of ADC

AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC

    for(i=0; i<5000; i++){} // wait 60000 cycles = 1ms (each iteration is 12 cycles)

 

AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; // create int pulses 1 cycle prior to output latch

 

// set S/H window to 6 clk cycles (117ns)

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;

AdcRegs.ADCSOC1CTL.bit.ACQPS = 6;

AdcRegs.ADCSOC2CTL.bit.ACQPS = 6;

AdcRegs.ADCSOC4CTL.bit.ACQPS = 6;

AdcRegs.ADCSOC7CTL.bit.ACQPS = 6;

AdcRegs.ADCSOC9CTL.bit.ACQPS = 63;

AdcRegs.ADCSOC10CTL.bit.ACQPS = 6;

AdcRegs.ADCSOC11CTL.bit.ACQPS = 6;

AdcRegs.ADCSOC12CTL.bit.ACQPS = 6;

AdcRegs.ADCSOC14CTL.bit.ACQPS = 6;

AdcRegs.ADCSOC15CTL.bit.ACQPS = 6;

 

 

AdcRegs.INTSEL1N2.bit.INT1SEL = 14; // ADCCH14 (ADC-B6) EOC causes ADCInterrupt 1

AdcRegs.INTSEL1N2.bit.INT1CONT = 0; // set ADCInterrupt 1 to auto clr

AdcRegs.INTSEL1N2.bit.INT1E = 1; // enable ADC interrupt 1

//AdcRegs.ADCSOC9CTL.bit.TRIGSEL = 0;

 AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1;  // SOC0 will be triggered from INT1(plus whatever TRIGSEL is set to)

/*************************************************************************************************/

 

//EOC = end of conversion event; SOC = start of conversion event

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

  AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1;

   AdcRegs.ADCINTSOCSEL1.bit.SOC2 = 1;

   AdcRegs.ADCINTSOCSEL1.bit.SOC4 = 1;

   AdcRegs.ADCINTSOCSEL1.bit.SOC7 = 1;

AdcRegs.ADCINTSOCSEL2.bit.SOC9 = 1;

   AdcRegs.ADCINTSOCSEL2.bit.SOC10 = 1;

   AdcRegs.ADCINTSOCSEL2.bit.SOC11 = 1;

   AdcRegs.ADCINTSOCSEL2.bit.SOC12 = 1;

AdcRegs.ADCINTSOCSEL2.bit.SOC14 = 1;

   AdcRegs.ADCINTSOCSEL2.bit.SOC15 = 1;

 

 //Select the channel to be converted when SOCx is received

AdcRegs.ADCSOC0CTL.bit.CHSEL= 0; // convert ADC-A0 (CH0) when SOC0 is received

AdcRegs.ADCSOC1CTL.bit.CHSEL= 1; // convert ADC-A1 (CH1) when SOC1 is received

AdcRegs.ADCSOC2CTL.bit.CHSEL= 2;

AdcRegs.ADCSOC4CTL.bit.CHSEL= 4;

AdcRegs.ADCSOC7CTL.bit.CHSEL= 7;

AdcRegs.ADCSOC9CTL.bit.CHSEL= 9; // convert ADC-B1 (CH9) when SOC9 is received

AdcRegs.ADCSOC10CTL.bit.CHSEL= 10;

AdcRegs.ADCSOC11CTL.bit.CHSEL= 11;

AdcRegs.ADCSOC12CTL.bit.CHSEL= 12;

AdcRegs.ADCSOC14CTL.bit.CHSEL= 14;

AdcRegs.ADCSOC15CTL.bit.CHSEL= 15;

 

EDIS;

 

AdcRegs.ADCSOCFRC1.all = 0x4000;   // kick start ADC by causing a SOC14 event

 

Thanks

  • When is the ADC ISR being serviced?  From your code INT1 is tied to EOC14, which then will re-trigger all the conversions again.  From round robin scheme this will mean that INT1 will come immediately after your 1st force; and will need to be cleared before EOC14 is reached again.  This should take a bit of time, since SOC15 will be the 1st ADC SOC to be initiated by the INTSOCSEL selection.  However, if you don't clear the INT1 flag before the EOC14(and the INT1) comes again there will be no more conversions or INTs since the ADC will stop. 

    Best,

    Matthew