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 SEQ2 doesn't work. [ F28335 / Dual Sequencer Mode ]

Hi,

I have a question about F28335's ADC.

My device setting is following.
- Simultaneous Sampling
- Dual Sequencer Mode
- ADC trigger is SOCA & SOCB of ePWM1

Now, Sequencer2(SEQ2) doesn't work.

ETFLG->SOCA & SOCB is set. But SEQ2 isn't triggered.

My program is following.

Please let me know when you find out about it.

--------------------------------------------------------------------------------------------

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

AdcRegs.ADCTRL2.bit.RST_SEQ1 = 0x1;
AdcRegs.ADCTRL2.bit.RST_SEQ2 = 0x1;

/* ADC Config */
AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK;
AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS;
AdcRegs.ADCTRL1.bit.SEQ_CASC = 0;
AdcRegs.ADCTRL3.bit.SMODE_SEL = 1;
AdcRegs.ADCTRL1.bit.CONT_RUN = 1;
AdcRegs.ADCTRL1.bit.SEQ_OVRD = 0;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;
AdcRegs.ADCTRL2.bit.SOC_SEQ2 = 1;

/* SEQ1 Config */
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 3;

/* SEQ2 Config */
AdcRegs.ADCTRL2.bit.EPWM_SOCB_SEQ2 = 1;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0;
AdcRegs.ADCCHSELSEQ3.bit.CONV09 = 0;
AdcRegs.ADCCHSELSEQ3.bit.CONV10 = 0;
AdcRegs.ADCCHSELSEQ3.bit.CONV11 = 0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV2 = 3;

// Assumes ePWM1 clock is already enabled in InitSysCtrl();
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 4; // Select SOC from from CPMA on upcount

EPwm1Regs.ETSEL.bit.SOCBEN = 1; // Enable SOC on B group
EPwm1Regs.ETSEL.bit.SOCBSEL = 4; // Select SOC from from CPMA on upcount

EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate SOCA pulse on 1st event
EPwm1Regs.ETPS.bit.SOCBPRD = 1; // Generate SOCB pulse on 1st event
EPwm1Regs.CMPA.half.CMPA = 0x0080; // Set compare A value
EPwm1Regs.TBPRD = 0xFFFF; // Set period for ePWM1
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // count up and start

------------------------------------------------------------------------

Best regards,

FSSer

  • Hi FSSer,

    The above ADC configuration seems to be incorrect.

    Try this: Simply replace the above code with the one attached below

     // Configure ADC
          AdcRegs.ADCMAXCONV.all = 0x0005;       // Setup 3 conv's on SEQ1
          AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0; // Setup ADCINA0 as 1st SEQ1 conv.			
          AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1; // Setup ADCINA1 as 2nd SEQ1 conv.			
          AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2; // Setup ADCINA2 as 3rd SEQ1 conv.			
          AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x3; // Setup ADCINA3 as 4th SEQ1 conv.			
          AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x4; // Setup ADCINA4 as 1st SEQ2 conv.			
          AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x5; // Setup ADCINA5 as 2nd SEQ2 conv.			
          AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x6; // Setup ADCINA6 as 2nd SEQ2 conv.			
    
    
         AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
         AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;  // Enable SEQ1 interrupt (every EOS)
         AdcRegs.ADCTRL2.bit.EPWM_SOCB_SEQ2 = 1;// Enable SOCB from ePWM to start SEQ2
         AdcRegs.ADCTRL2.bit.INT_ENA_SEQ2 = 1;  // Enable SEQ2 interrupt (every EOS)

    Also, you can select any ADC channel as per your requirement. Mine above is from ADC0-6.

    Regards,

    Gautam

  • Hi Gautam,

    Thank you for your reply.

    But still does not work.

    Please teach us about the following.

    In the description of ADC RG(spru812a) Dual Sequencer Mode : 

    SEQ1 is CONV00~CONV07
    SEQ2 is CONV08~CONV15

    and,

    Example 1-1. Simultaneous Sampling Dual Sequencer Mode Example is : 18page

    I have programmed it to the reference.

    This is correct ?   --->  SEQ1 = CONV00~CONV0 & SEQ2 = CONV08~CONV15 in Dual Sequencer Mode.

    Regards,

    FSSer

  • Now, My program is working properly after  I modfied ADCTRL1.bit.CONT_RUN = 0.

    This thread I will close.

    Thanks & regards,

    FSSer

  • That's Great FSSer!

    Goodluck & Regards,
    Gautam