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/TMS320F2808: TMS320F2808

Part Number: TMS320F2808

Tool/software: Code Composer Studio

I have written a code for conversion of 9 ADC channels. I have used cascaded mode of conversion. The ADC is software triggered. The trigger source is placed in a timer0 ISR which is executed for every 1msec. The timer0 is running perfectly but the ADC conversion is not happening. I tried my best to debug it but still, the problem persists. Can anyone help? The code is given below.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#include "DSP280x_Device.h"
#include "DSP280x_Examples.h"

__interrupt void cpu_timer0_isr(void);
interrupt void adc_isr(void)

void main(void)
{
InitSysCtrl();

DINT;

InitPieCtrl();

IER = 0x0000;
IFR = 0x0000;

InitPieVectTable();

InitAdc();

AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK; //ADC Initialization to run in cascaded mode. 9 channels conversion.
AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS;
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;
AdcRegs.ADCTRL1.bit.CONT_RUN = 1;
AdcRegs.ADCTRL1.bit.SEQ_OVRD = 1;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x4;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x5;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x6;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x7;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x8;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0x8;
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ2 = 1;

EALLOW;
SysCtrlRegs.HISPCP.all = ADC_MODCLK;
EDIS;

EALLOW;
PieVectTable.TINT0 = &cpu_timer0_isr;
PieVectTable.ADCINT = &adc_isr;
EDIS;

InitCpuTimers();

ConfigCpuTimer(&CpuTimer0, 100, 1000);
CpuTimer0Regs.TCR.all = 0x4000;


IER |= M_INT1;


PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;


EINT;
ERTM;

for(;;)
{
__asm("NOP");
}
}

__interrupt void cpu_timer0_isr(void) //Timer for every 1msec
{
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; // Enable software trigger for SEQ1
AdcRegs.ADCTRL2.bit.RST_SEQ2 = 1;
AdcRegs.ADCTRL2.bit.SOC_SEQ2 = 1; // Enable software trigger for SEQ2
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}

interrupt void adc_isr(void)
{

a[0]=AdcRegs.ADCRESULT0 >>4;
a[1]=AdcRegs.ADCRESULT1 >>4;
a[2]=AdcRegs.ADCRESULT2 >>4;
a[3]=AdcRegs.ADCRESULT3 >>4;
a[4]=AdcRegs.ADCRESULT4 >>4;
a[5]=AdcRegs.ADCRESULT5 >>4;
a[6]=AdcRegs.ADCRESULT6 >>4;
a[7]=AdcRegs.ADCRESULT7 >>4;
a[8]=AdcRegs.ADCRESULT8 >>4;
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reinitialize for next ADC sequence
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
AdcRegs.ADCTRL2.bit.RST_SEQ2 = 1; // Reinitialize for next ADC sequence
AdcRegs.ADCST.bit.INT_SEQ2_CLR = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE

return;
}

  • Ashwin,

    Can you define the behavior of "ADC conversion is not happening" in your example?  Are the result register never updating or are you not triggering the ADC interrupt?

    Based on your description, you may want to consider:

    1. Clearing SEQ_OVRD so that the ADC conversions automatically wrap back to CONV00 rather than manually doing so with the RST_SEQ bits
    2. Enabling INT_SEQ1 in case that is the primary interrupt signal in cascaded mode

    -Tommy

  • Interrupt is not happening. So if I'm using INT_SEQ1 for clearing flag after interrupt occured is it enuf if I set
    AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; alone? Will the adc be converted from A0,A1,A2.....B0 respectively? or will it be like A0,B0,A1,.....A7?
  • Ashwin,

    The INT_SEQx bits will not have any effect on the sequencer operation.  They only control how the interrupt signal to the CPU / system is generated and how they are serviced in the ISR.

    I see that you have INT_SEQ2 enabled (AdcRegs.ADCTRL2.bit.INT_ENA_SEQ2 = 1), but I do not see INT_SEQ1 enabled.

    -Tommy

  • I have enabled it still it is not working. I considered a different code. Here what i do is I sense three values and do some calculations and update the PWM. The adc interrupt is happening but the conversion value is always 0.

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    #include "DSP280x_Device.h"
    #include "DSP280x_Examples.h"
    #include "math.h"

    int i=0;
    float Va,Vb,Vc;


    #define ADC_MODCLK 0x4
    #define ADC_CKPS 0x0
    #define ADC_SHCLK 0x1

    typedef struct
    {
    volatile struct EPWM_REGS *EPwmRegHandle;
    }EPWM_INFO;

    void InitEPwm1Example(void);
    void InitEPwm2Example(void);
    void InitEPwm3Example(void);
    void InitEPwm4Example(void);

    __interrupt void cpu_timer0_isr(void);
    __interrupt void epwm1_isr(void);
    void setup_Adc(void);
    interrupt void adc_isr(void);

    int EPWM1_CMPA=0;
    int EPWM2_CMPA=0;
    int EPMW3_CMPA=0;
    int EPWM4_CMPA=0;


    void main(void)
    {
    InitSysCtrl();

    InitEPwm1Gpio();
    InitEPwm2Gpio();
    InitEPwm3Gpio();
    InitEPwm4Gpio();

    DINT;

    InitAdc();
    setup_Adc();

    InitPieCtrl();

    IER = 0x0000;
    IFR = 0x0000;

    InitPieVectTable();

    EALLOW;
    PieVectTable.EPWM1_INT = &epwm1_isr;
    PieVectTable.TINT0 = &cpu_timer0_isr;
    PieVectTable.ADCINT = &adc_isr;
    EDIS;

    InitCpuTimers();


    ConfigCpuTimer(&CpuTimer0, 100, 1000);
    CpuTimer0Regs.TCR.all = 0x4000;

    EALLOW;
    GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO14 = 1;
    EDIS;

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    InitEPwm1Example();
    InitEPwm2Example();
    InitEPwm3Example();
    InitEPwm4Example();

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;

    IER |= M_INT3;
    IER |= M_INT1;


    PieCtrlRegs.PIEIER3.bit.INTx1 = 1;
    PieCtrlRegs.PIEIER3.bit.INTx2 = 1;
    PieCtrlRegs.PIEIER3.bit.INTx3 = 1;
    PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;


    EINT;
    ERTM;

    // Step 6. IDLE loop. Just sit and loop forever (optional):
    for(;;)
    {
    __asm("NOP");
    }
    }


    __interrupt void cpu_timer0_isr(void)
    {
    AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }

    __interrupt void epwm1_isr(void)
    {

    EPwm1Regs.CMPA.half.CMPA = w;
    EPwm2Regs.CMPA.half.CMPA = x;
    EPwm3Regs.CMPA.half.CMPA = y;
    EPwm4Regs.CMPA.half.CMPA = z;

    // Clear INT flag for this timer
    EPwm1Regs.ETCLR.bit.INT = 1;

    // Acknowledge this interrupt to receive more interrupts from group 3
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
    }



    void InitEPwm1Example()
    {
    // Setup TBCLK
    EPwm1Regs.TBPRD = 2500;
    EPwm1Regs.TBPHS.half.TBPHS = 0x0000;
    EPwm1Regs.TBCTR = 0x0000;

    // Set Compare values
    EPwm1Regs.CMPA.half.CMPA = EPWM1_CMPA;

    // Setup counter mode
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2;
    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;

    // Set actions
    EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;
    EPwm1Regs.AQCTLA.bit.CAD = AQ_SET;

    EPwm1Regs.DBCTL.bit.OUT_MODE=DB_FULL_ENABLE;
    EPwm1Regs.DBCTL.bit.POLSEL=DB_ACTV_HIC;
    EPwm1Regs.DBCTL.bit.IN_MODE=DBA_ALL;
    EPwm1Regs.DBRED=100;
    EPwm1Regs.DBFED=100;

    // Interrupt where we will change the Compare Values
    EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;
    EPwm1Regs.ETSEL.bit.INTEN = 1;
    EPwm1Regs.ETPS.bit.INTPRD = ET_1ST;
    }

    void InitEPwm2Example()
    {
    EPwm2Regs.TBPRD = 2500;
    EPwm2Regs.TBPHS.half.TBPHS = 0x0000;
    EPwm2Regs.TBCTR = 0x0000;

    // Set Compare values
    EPwm2Regs.CMPA.half.CMPA = EPWM1_CMPA;

    // Setup counter mode
    EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE;
    EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2;
    EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;

    // Set actions
    EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR;
    EPwm2Regs.AQCTLA.bit.CAD = AQ_SET;

    EPwm2Regs.DBCTL.bit.OUT_MODE=DB_FULL_ENABLE;
    EPwm2Regs.DBCTL.bit.POLSEL=DB_ACTV_HIC;
    EPwm2Regs.DBCTL.bit.IN_MODE=DBA_ALL;
    EPwm2Regs.DBRED=100;
    EPwm2Regs.DBFED=100;
    }

    void InitEPwm3Example(void)
    {
    EPwm3Regs.TBPRD = 2500;
    EPwm3Regs.TBPHS.half.TBPHS = 0x0000;
    EPwm3Regs.TBCTR = 0x0000;

    // Set Compare values
    EPwm3Regs.CMPA.half.CMPA = EPWM1_CMPA;

    // Setup counter mode
    EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE;
    EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2;
    EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV1;

    // Set actions
    EPwm3Regs.AQCTLA.bit.CAU = AQ_CLEAR;
    EPwm3Regs.AQCTLA.bit.CAD = AQ_SET;

    EPwm3Regs.DBCTL.bit.OUT_MODE=DB_FULL_ENABLE;
    EPwm3Regs.DBCTL.bit.POLSEL=DB_ACTV_HIC;
    EPwm3Regs.DBCTL.bit.IN_MODE=DBA_ALL;
    EPwm3Regs.DBRED=100;
    EPwm3Regs.DBFED=100;
    }

    void InitEPwm4Example(void)
    {
    EPwm4Regs.TBPRD = 2500;
    EPwm4Regs.TBPHS.half.TBPHS = 0x0000;
    EPwm4Regs.TBCTR = 0x0000;

    // Set Compare values
    EPwm4Regs.CMPA.half.CMPA = EPWM1_CMPA;

    // Setup counter mode
    EPwm4Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    EPwm4Regs.TBCTL.bit.PHSEN = TB_DISABLE;
    EPwm4Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2;
    EPwm4Regs.TBCTL.bit.CLKDIV = TB_DIV1;

    // Set actions
    EPwm4Regs.AQCTLA.bit.CAU = AQ_CLEAR;
    EPwm4Regs.AQCTLA.bit.CAD = AQ_SET;

    EPwm4Regs.DBCTL.bit.OUT_MODE=DB_FULL_ENABLE;
    EPwm4Regs.DBCTL.bit.POLSEL=DB_ACTV_HIC;
    EPwm4Regs.DBCTL.bit.IN_MODE=DBA_ALL;
    EPwm4Regs.DBRED=100;
    EPwm4Regs.DBFED=100;
    }

    interrupt void adc_isr(void)
    {

    GpioDataRegs.GPATOGGLE.bit.GPIO14=1;

    A[0]=AdcRegs.ADCRESULT0 >> 4;
    A[1]=AdcRegs.ADCRESULT1 >> 4;
    A[2]=AdcRegs.ADCRESULT2 >> 4;

    \\Space Vector Modulation code

    // Reinitialize for next ADC sequence
    AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;
    AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    return;
    }

    void setup_Adc(void)
    {
    EALLOW;
    SysCtrlRegs.HISPCP.all = 0x4;
    EDIS;

    // Configure ADC
    AdcRegs.ADCMAXCONV.all = 0x0002;
    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
    AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1;
    AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2;
    AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;
    }
  • Ashwin,

    Reading back all zeros is very peculiar.  Are you using a TI EVM or a custom board?  Does a standard example like "adc_soc" work?  Can you confirm that InitAdc() is setting the power-up bits as expected?  Do the AdcMirror() registers also read back zeros?

    -Tommy

  • Ashwin,

    Are you still having issues?

    -Tommy
  • No, I have not resolved it yet.

    In order to test the proper functioning of ADC, I tried the following code. I am basically reading a value in the ADC pin 1 and accordingly changing my duty ratio in epwm1. The output of epwm is zero.

    The ADC interrupt is happening I checked it using a GPIO14 pin.

    When I changed the line w=2500*V/4095; to w=1250; in the ADC service routine I get a pulse with 50% duty ratio and that is right. So, the question is why is it not working for w=2500*V/4095; I suspect that the ADC reads a 0. Any thoughts on this issue as to how to solve it?

    I provide the ADC pin with a voltage of 1.5V.

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    #include "DSP280x_Device.h"
    #include "DSP280x_Examples.h"
    int w=0;

    typedef struct
    {
    volatile struct EPWM_REGS *EPwmRegHandle;
    }EPWM_INFO;

    void InitEPwm1Example(void);

    __interrupt void cpu_timer0_isr(void);

    interrupt void adc_isr(void);

    void main(void)
    {

    InitSysCtrl();

    InitEPwm1Gpio(); \\Setup Pin as PWM

    DINT;

    InitPieCtrl();



    IER = 0x0000;
    IFR = 0x0000;

    InitPieVectTable();

    EALLOW;
    PieVectTable.ADCINT = &adc_isr;
    EDIS;

    EALLOW;
    PieVectTable.TINT0 = &cpu_timer0_isr;
    EDIS;

    EALLOW;
    GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO14 = 1;
    EDIS;

    InitCpuTimers(); \\ Setup timer for 1kHz
    ConfigCpuTimer(&CpuTimer0, 100, 1000);
    CpuTimer0Regs.TCR.all = 0x4000;

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    InitEPwm1Example();

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;

    IER |= M_INT3;
    IER |= M_INT1;

    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
    PieCtrlRegs.PIEIER1.bit.INTx6 = 1;

    \\Initializing ADC
    EALLOW;
    SysCtrlRegs.HISPCP.all = 0x4;
    EDIS;
    InitAdc();
    AdcRegs.ADCMAXCONV.all = 0x0001; // Setup 2 conv's on SEQ1
    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x1;
    AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2;
    AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;

    EINT;
    ERTM;

    for(;;)
    {
    __asm("NOP");
    }
    }

    __interrupt void cpu_timer0_isr(void) \\Interrupt after every 1msec
    {

    EPwm1Regs.CMPA.half.CMPA = w; \\updation of CMPA

    AdcRegs.ADCTRL2.bit.SOC_SEQ1=1; \\Forcing ADC conversion

    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }

    void InitEPwm1Example()
    {
    EPwm1Regs.TBPRD = 2500;
    EPwm1Regs.TBPHS.half.TBPHS = 0x0000;
    EPwm1Regs.TBCTR = 0x0000;

    EPwm1Regs.CMPA.half.CMPA = 0;

    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD;

    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2;
    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;

    EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;
    EPwm1Regs.AQCTLA.bit.CAD = AQ_SET;

    EPwm1Regs.DBCTL.bit.OUT_MODE=DB_FULL_ENABLE;
    EPwm1Regs.DBCTL.bit.POLSEL=DB_ACTV_HIC;
    EPwm1Regs.DBCTL.bit.IN_MODE=DBA_ALL;
    EPwm1Regs.DBRED=10;
    EPwm1Regs.DBFED=10;
    }

    interrupt void adc_isr(void)
    {

    GpioDataRegs.GPATOGGLE.bit.GPIO14=1; \\To check the adc interrupt occurance
    V= AdcRegs.ADCRESULT0 >>4;
    w= (int) 2500*V/4095;

    // Reinitialize for next ADC sequence
    AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
    AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE

    return;
    }
  • Hello, Can anyone please help I am out of ideas!
  • Ashwin,

    Where are you looking when you say that the results are all 0? Have you tried to observe the ADCRESULT or ADCMIRROR registers directly from a CCS memory or expression window?

    Also, where are your ADC result variables (such as V or A[] or a[]) declared? I cannot verify the variable scope.

    -Tommy
  • Thanks for reply Tommy.

    Please observe the following code alone. I am observing the value from the expression window and it it zero.

    Also, I am updating my CMPA of epwm1 using the ADC read value.The following is the code for updation.
    V= AdcRegs.ADCRESULT0 >>4;
    w= (int) 2500*V/4095;
    EPwm1Regs.CMPA.half.CMPA = w;

    I find the epwm output also to be zero proving that the ADC conversion to be zero.

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    #include "DSP280x_Device.h"
    #include "DSP280x_Examples.h"
    int w=0,V=0;

    typedef struct
    {
    volatile struct EPWM_REGS *EPwmRegHandle;
    }EPWM_INFO;

    void InitEPwm1Example(void);

    __interrupt void cpu_timer0_isr(void);

    interrupt void adc_isr(void);

    void main(void)
    {

    InitSysCtrl();

    InitEPwm1Gpio(); \\Setup Pin as PWM

    DINT;

    InitPieCtrl();



    IER = 0x0000;
    IFR = 0x0000;

    InitPieVectTable();

    EALLOW;
    PieVectTable.ADCINT = &adc_isr;
    EDIS;

    EALLOW;
    PieVectTable.TINT0 = &cpu_timer0_isr;
    EDIS;

    EALLOW;
    GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO14 = 1;
    EDIS;

    InitCpuTimers(); \\ Setup timer for 1kHz
    ConfigCpuTimer(&CpuTimer0, 100, 1000);
    CpuTimer0Regs.TCR.all = 0x4000;

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    InitEPwm1Example();

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;

    IER |= M_INT3;
    IER |= M_INT1;

    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
    PieCtrlRegs.PIEIER1.bit.INTx6 = 1;

    \\Initializing ADC
    EALLOW;
    SysCtrlRegs.HISPCP.all = 0x4;
    EDIS;
    InitAdc();
    AdcRegs.ADCMAXCONV.all = 0x0001; // Setup 2 conv's on SEQ1
    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x1;
    AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2;
    AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;

    EINT;
    ERTM;

    for(;;)
    {
    __asm("NOP");
    }
    }

    __interrupt void cpu_timer0_isr(void) \\Interrupt after every 1msec
    {

    EPwm1Regs.CMPA.half.CMPA = w; \\updation of CMPA

    AdcRegs.ADCTRL2.bit.SOC_SEQ1=1; \\Forcing ADC conversion

    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }

    void InitEPwm1Example()
    {
    EPwm1Regs.TBPRD = 2500;
    EPwm1Regs.TBPHS.half.TBPHS = 0x0000;
    EPwm1Regs.TBCTR = 0x0000;

    EPwm1Regs.CMPA.half.CMPA = 0;

    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD;

    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2;
    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;

    EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;
    EPwm1Regs.AQCTLA.bit.CAD = AQ_SET;

    EPwm1Regs.DBCTL.bit.OUT_MODE=DB_FULL_ENABLE;
    EPwm1Regs.DBCTL.bit.POLSEL=DB_ACTV_HIC;
    EPwm1Regs.DBCTL.bit.IN_MODE=DBA_ALL;
    EPwm1Regs.DBRED=10;
    EPwm1Regs.DBFED=10;
    }

    interrupt void adc_isr(void)
    {

    GpioDataRegs.GPATOGGLE.bit.GPIO14=1; \\To check the adc interrupt occurance
    V= AdcRegs.ADCRESULT0 >>4;
    w= (int) 2500*V/4095;

    // Reinitialize for next ADC sequence
    AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
    AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE

    return;
    }
  • Ashwin,

    Can you run the unmodified adc_soc example from the software support package to see if you get expected ADC results?  I want to make sure that your device is not defective.

    -Tommy

  • I checked that too the output was the same, it gave zero. Then I switched to another controlcard F28044 and tried out the adc_soc program in that as well and same problem was coming.
  • I cross-referred the adcinit() function of F2808 and F28335.
    The statement SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; which was there in F28335 was missing in F2808 and F28044.
    Can this be the problem?
  • Ashwin,

    Yes, this will be an issue if ADCENCLK is not set. It would definitely lead to reading all 0s from the ADCRESULT registers, but you would also not be able to access the ADC configuration registers either. Since you reported that the ADC interrupts were working, I did not think that the ADCENCLK bit was a likely factor.

    Are you able to confirm that this bit is set in your software?

    -Tommy
  • I am sorry it is set in my program. but still the conversion is not happening.
  • Ashwin,

    Let's sanity check your setup.

    Confirm that these components are populated on the controlCARD:

    • C30 (ADC-REFP)
    • C31 (ADC-REFM)
    • R2 (ADC-RESEXT)

    Then force the following voltages on the dock:

    • 1.5V to A2 (dock pin 61)
    • 0V to GND (dock pin 62)
    • 1.5V to A3 (dock pin 63)

    Measure the forced voltage levels on the controlCARD:

    • C25 terminals (A2 and GND)
    • C24 terminals (A3 and GND)

    If all looks good, extract a fresh, unmodified copy of the F2808 adc_soc example to see if the conversions are around 2048 for a 1.5V force voltage.

    -Tommy

  • Ashwin,

    It has been over two weeks since your last update. I assume that you were able to resolve your issue. If this isn’t the case, please reject this resolution and reply to this thread. If this thread is locked, please make a new thread describing the current status of your issue.

    -Tommy