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.

ISR for ADC is not working on F28335



Hi,

To all,

I m working on ADC. As per example i have taken ADC sample in continuous polling like this way

 

EALLOW;

SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;

ADC_cal();

EDIS;

    AdcRegs.ADCTRL3.all = 0x00E0;  // Power up bandgap/reference/ADC circuits

    delay(50000);         // Delay before converting ADC channels

   delay(50000);

   AdcRegs.ADCTRL1.bit.ACQ_PS = 14;

   AdcRegs.ADCTRL3.bit.ADCCLKPS = 15;

   AdcRegs.ADCTRL1.bit.CPS = 1;

   AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;        // 1  Cascaded mode

   AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;

   AdcRegs.ADCTRL1.bit.CONT_RUN = 1;       // Setup continuous run

   AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 0x1;

AdcRegs.ADCTRL2.all = 0x2000;

for(;;)   

{

     while (AdcRegs.ADCST.bit.INT_SEQ1== 0) {} // Wait for interrupt 

         AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;                             

        SampleTable[index] =((AdcRegs.ADCRESULT0>>4) );

}

By this method i am getting sample but when I want to go for interrupt base sampling than there is no interrupt generation it means it is not going in to ISR even for a single time below is the intterupt based code.

 

EALLOW;  // This is needed to write to EALLOW protected registers

PieVectTable.TINT0 = &cpu_timer0_isr;

PieVectTable..ADCINT= &ADC_isr;

EDIS;

EALLOW;

 

SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;

ADC_cal();

EDIS;

    AdcRegs.ADCTRL3.all = 0x00E0;  // Power up bandgap/reference/ADC circuits

    delay(50000);         // Delay before converting ADC channels

   delay(50000);

 

   AdcRegs.ADCTRL1.bit.ACQ_PS = 14;

   AdcRegs.ADCTRL3.bit.ADCCLKPS = 15;

   AdcRegs.ADCTRL1.bit.CPS = 1;

   AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;        // 1  Cascaded mode

   AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;

   AdcRegs.ADCTRL1.bit.CONT_RUN = 1;       // Setup continuous run

   AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 0x1;

// Enable TINT0 in the PIE: Group 1 interrupt 7

   PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

   PieCtrlRegs.PIEIER1.bit.INTx6 = 1;

   IER |= M_INT1;

// Enable global Interrupts and higher priority real-time debug events:

   EINT;   // Enable Global interrupt INTM

   ERTM;   // Enable Global realtime interrupt DBGM

 

AdcRegs.ADCTRL2.all = 0x2000;

for(;;){}

 

 interrupt void ADC_isr(void)                         

 {                                                 

     SampleTable[index] =((AdcRegs.ADCRESULT0>>4) ); 

  index++;                                        

  if(index==499)                                  

  {                                               

  index = 0;                                                 

  }                                                                                               

  else AdcRegs.ADCRESULT0;                         

 

     AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;         // Reset SEQ1                                                  

     AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;              

     PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;             

 }

referance for this also i have taken from the TI example but still its not Working

 

Has anyone faced this kind of problem in ADC ISR than just help me.

Now i am planning to start DMA for ADC data.

Thanks in Advance..

Regards,

Chintan

  • Hello,

     

    try to look through the example in spra958h document
    http://focus.ti.com/general/docs/techdocsabstract.tsp?abstractName=spra958h
    it has an interrupt based ADC and works perfectly well.

  • Thanks,

    Alexander

     

    I have seent that example and according to that example i am able to get ADC interrupt but in this example SOC is on ePWM_SOCA_SEQ1, 1=SEQ1 start from ePWM_SOCA trigger, but i want to make it in Software trigger base as i want to start it once and want to get regular interrupt at End of conversion in Continuous mode conversion....

    as i showed there in my abovw written code but i m not getting interrupt only once and if i see it in While loop on pllin bases than i am able to get the conversion so is there anybody who has done coding in software trigger ISR in continuous mode than please help me....

     

    regards,

    Chintan 

  • Chintan,

    This line looks suspect:

     

    PieVectTable..ADCINT= &ADC_isr;

    Notice the double ".."  I think this should be

    PieVectTable.ADCINT = &ADC_isr;

    In this case it is the ISR that is not getting set properly; can you confirm that the ADC is still running and updating RESULT0? 

    Also this line in the ISR:

    AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;         // Reset SEQ1              

    Is not needed; since MAXCONV1 = 0; and in Continuous run mode the sequencer automatically resets after MAXCONV is reached.  In general I would avoid resetting the sequencer(s) while the ADC is converting; as this could result in an indeterminate state.

    Finally, I'm not sure of this line:

    elseAdcRegs.ADCRESULT0;  

    Best,

    Matthew

                                        

  • Hi mathew,

    Thanks for the reply i have corrected that instruction after sending you this post and that was not a problem i have solved the problem now i am getting the interrupt for ADC afte rsequencing the insruction previously i was writting The Whole ADCTRL2 register to strt the conversion(SOC)

    After reading in the datasheet i have change it and i am using bit wise operation to start the conversion after reset and this two bit wise operation i am using just before While(1);

    Now i am struggling to get proper reading of my analog input it is not perfect like it was in Polling base code right now it is not following input it follows input in group and i am trying to solve that

    Thanks for the reply

    Regards,

    Chintan