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.

Time consumption in performs an ADC

Hi people, I have a question about ADC,  make three conversions and look that is too long time about 1 us.

Anybody can review if I make a wrong program?

I put the little piece of code:

  

AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;

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

    ILsensed = AdcMirror.ADCRESULT0;

    vi_11 = AdcMirror.ADCRESULT1;

    vo_11 = AdcMirror.ADCRESULT2;

AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;

AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; 

// Reset SEQ1

  • Are you able to post the disassembly of this C code? Also can this include the full three conversions (or the loop to do them).

    I ask this is the 1us looks like a mix between ADC conversion time and code efficiency.  1us does seem a little to long I would expect more like 5-600ns off the top of my head, but the disassembly will allow me (and others) to decide whether its just the processor taking a while or the an issue with your ADC conversions. 

    Tim

     

  • Sorry Tim by delay my ask, below, put the C code and dissasembly lines:

    The C code:

    AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;

     

    //enable el ADC desde el SOC del SEQ1

     

    //GpioDataRegs.GPASET.bit.GPIO2 = 1; // on GPIO2

     

    while (AdcRegs.ADCST.bit.INT_SEQ1== 0) {}

    // Wait for interrupt

    ILsensed = AdcRegs.ADCRESULT0;

    vi_11 = AdcRegs.ADCRESULT1;

    vo_11 = AdcRegs.ADCRESULT2;

    AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;

    AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;

     

    // Reset SEQ1

    The assembler code:

    0x0093D2:   761F01C4    MOVW       DP,#0x01C4
    0x0093D4:   1A012000    OR         @1,#0x2000
              C$DW$L$_main$5$B, C$L4, C$DW$L$_main$4$E:
    0x0093D6:   4019        TBIT       @25,#0
    0x0093D7:   EFFF        SBF        C$DW$L$_main$4$E,NTC
              C$DW$L$_main$6$B, C$DW$L$_main$5$E:
    0x0093D8:   9208        MOV        AL,@8
    0x0093D9:   761F0300    MOVW       DP,#0x0300
    0x0093DB:   9600        MOV        @0,AL
    0x0093DC:   761F01C4    MOVW       DP,#0x01C4
    0x0093DE:   9209        MOV        AL,@9
    0x0093DF:   761F0300    MOVW       DP,#0x0300
    0x0093E1:   9601        MOV        @1,AL
    0x0093E2:   761F01C4    MOVW       DP,#0x01C4
    0x0093E4:   920A        MOV        AL,@10
    0x0093E5:   761F0300    MOVW       DP,#0x0300
    0x0093E7:   9606        MOV        @6,AL
    0x0093E8:   761F01C4    MOVW       DP,#0x01C4
    0x0093EA:   1A190010    OR         @25,#0x0010
    0x0093EC:   1A014000    OR         @1,#0x4000