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.

Too many results from ADC conversions.

Hi all,

I am re-writing some of the "DMC-library" drivers from F2808 to F28335.

I have some difficulties with the ADC Driver.

I have simply coded:

// Enable CNT_zero interrupt using EPWM1 Time-base
    EPwm1Regs.ETSEL.bit.INTEN = 1;   // Enable EPWM1INT generation
    EPwm1Regs.ETSEL.bit.INTSEL = 1;  // Enable interrupt CNT_zero event
    EPwm1Regs.ETPS.bit.INTPRD = 1;   // Generate interrupt on the 1st event
    EPwm1Regs.ETCLR.bit.INT = 1;     // Enable more interrupts

to generate 30Khz interrupts for the motor application.

Then I configure the ADC like this:

#define ADC_RESET_FLAG          0x4000

AdcRegs.ADCTRL1.all = ADC_RESET_FLAG;         // Reset the ADC Module
    asm(" NOP ");
    asm(" NOP ");
   
    InitAdc();


// Configure ADC
   AdcRegs.ADCMAXCONV.all = 0x0000;       // Setup 1 conv's on SEQ1
   AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0; // Setup ADCINA0
   AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1

This is just for testing and later I will add yet another conversion for the other channel.

The behaviour I get is very suspicious. See watch view below:

ADCRESULT0 = 0x0020
ADCRESULT1 = 0x0020
ADCRESULT2 = 0x0020
ADCRESULT3 = 0x0030
ADCRESULT4 = 0x0020
ADCRESULT5 = 0x0030
ADCRESULT6 = 0x0020
ADCRESULT7 = 0x0020

ADCRESULT8 = 0x0000
ADCRESULT9 = 0x0000
ADCRESULT10 = 0x0000
ADCRESULT11 = 0x0000
ADCRESULT12 = 0x0000
ADCRESULT13 = 0x0000
ADCRESULT14 = 0x0000
ADCRESULT15 = 0x0000
ADCTRL3 = 0x00E0
ADCST = 0x0001
ADCREFSEL = 0x219E
ADCOFFTRIM = 0x01FD

Somehow It makes more conversions than I want. It is writing to 8 result-buffers and I can not see why.

Thanks,

 

  • Alborz,

    The ADC on these devices are controlled by 2 sequencers, SEQ1 populates results0-7 and SEQ2 populates results 8-15.  By default all conversions select channel 0, what is happening is every ePWM triggered SOC advances the sequencer state by 1 until it hit the end state(in this case7) then wraps back around.  This is start/stop mode for this ADC/sequencer.

    If you do not want the sequencer to advance, then you will need to monitor the sequencer interrupt either by polling or the ADC SEQ1 ISR and reset the sequencer in between triggers.  I'm assuming the ePWM is continuing to generate SOCs for this to be true if it is not, i.e. a one time only trigger, then the only other possiblity is that the ADC is in continous run mode bit CONT_RUN in ADCTRL1 is set.

    Best,

    Matthew

  • Hi Matthew and thanks for the reply.

    I am generating the interrupts via PWM and the conversions is needed right after each PWM updates.

    Therefore I can not use the CONT_RUN.

    What I don´t understand is why SEQ1 to SEQ7 are all being converted. I have specified only one conversion by using "AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0;" right?

    Thanks.

  • I'd make sure the SEQ_OVRD bit of the ADCTRL1 register is set to 0.  You've set up the ADC sequencer to sample one time, but the PWM will be constantly generating SOC signals and so you will get many conversions.  It looks like the sequencer isn't being reset after each conversion, so it will write consecutive sequences into the 8 results registers like a circular buffer.  This is useful for some applications, but it sounds like you want to just read the sample out each time so you'll want to make sure the sequencer resets each time.

    Hope this helps.