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.

How to SOC twice in a cycle by 28335 ?



Hi everyone:
     I want to sense Iav, Ipeak like figure to calculate subtraction. I set ePWM SOC trigger 2 event. But how to set adc_isr.

 

 ePWM setting:

// Setting the A/D Conversion

EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group

EPwm1Regs.ETSEL.bit.SOCASEL = 1; // Select SOC from from Zero on upcount
EPwm1Regs.ETSEL.bit.SOCASEL = 100; // TBPRD=COMA

EPwm1Regs.ETPS.bit.SOCACNT = 2; // 2 trigger event

EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate INT on first event

interrupt setting:

void SetInterrupt(void)

{

EALLOW;
PieVectTable.ADCINT = & adc_isr;
EDIS;
IER = M_INT1;
PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
EINT;
ERTM;
}

__interrupt void adc_isr(void)
{
Vo=AdcRegs.ADCRESULT0 >>4;
Vin=AdcRegs.ADCRESULT1 >>4;
IL=AdcRegs.ADCRESULT2 >>4;
PIcontroller();
EPwm1Regs.CMPA.half.CMPA = PFC_Duty;
// 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;
}


Thanks


  • Hi User4376808,

    It looks like you have setup one interrupt to occur based on the ADC that reads all the conversion results and does the control calculations.  If this is what you have intended this seems ok, the only thing missing are the ADC settings to configure the sequencer and for the ADC to trigger an interrupt at the end of the desired sequence.  Have you tried this, but it doesn't work, or are you not sure where to start?  

    Or is your question related to where you should trigger the interrupt and run your control algorithm?

  • Hi Devin,

    I want to sense Vin,Vo,IL by ePWM trigger 1, and sense IL again by trigger 2.
    Using IL,2 to subtract IL,1.
    But I don't know how set AdcRegs.ADCMAXCONV.all, AdcRegs.ADCASEQSR.bit.SEQ_CNTR.


    void SetADC(void)
    {
    InitAdc(); //Initialize ADC registers
    EALLOW;
    // Configure ADC
    AdcRegs.ADCMAXCONV.all = 0x2;
    AdcRegs.ADCASEQSR.bit.SEQ_CNTR = 0010;

    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
    AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1;
    AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2;
    AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x2;

    AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1; // Enable SOCA from ePWM to start SEQ1
    AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; // Software trigger
    AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every EOS)
    EDIS;
    }

    __interrupt void adc_isr(void)
    {
    Vo=AdcRegs.ADCRESULT0 >>4;
    Vin=AdcRegs.ADCRESULT1 >>4;
    IL=AdcRegs.ADCRESULT2 >>4;
    PIcontroller();
    EPwm1Regs.CMPA.half.CMPA = PFC_Duty;

    ILpeak=AdcRegs.ADCRESULT3 >>4;
    x=IL-ILpeak;

    // 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;
    }

    Thanks
  • Below is a sketch of what I think you want:

    You want dual sequencer mode, so you should set ADCCTRL1.SEQ_CASC = 0

    For SEQ1:
    -You have the trigger setup for SEQ1 as ePWM1, SOCA, up-count on zero -> this seems ok
    -I think you only need 3 conversions -> so ADCCHSELSEQ1.bit.CONV00 through CONV02 should be setup (but nothing for 3).
    -For ADCMAXCONV, the bottom 3 bits control SEQ1, and you want 3 conversions, so the bottom 3 bits are '2'.
    (SEQ_CNTR indicates the state of the sequencer, so no need to manipulate these manually)

    For SEQ2:
    -You need the trigger setups for SOCB based on whatever ePWM event you want
    -You only want one conversion here, so configure ADCCHSELSEQ2.bit.CONV08
    -Bits 0 to 2 control SEQ1 and bits 3-5 control SEQ2. Because you want one conversion, bits 3-5 = '0'.

    When the process is complete, SOCA trigger results are in result registers 0 through 2, SOCB results are in result register 8