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.

MSP430G2452: Energytrace, current pulse counting method

Part Number: MSP430G2452
Other Parts Discussed in Thread: ENERGYTRACE, MSP430F5528

I am trying to understand the pulse counting method of energytrace, the pulse counting is not done by the MSP430G2452 (which is solely responsible of the DCDC operations), instead the larger MSP430F5528 handles the DCDC pulse counting, target VCC monitoring, timestamping and USB streaming.
The sources of this firmware are scattered in MSPDebugStack_OS_Package_3_15_1_1\Bios and apparently some operations related to pulse counting are done in hil directory in particular hil.c where i can see

void hil_initTimerB0(void)
{
    // Setup timer_B0 for current pulse measurement
    TB0CTL = MC__STOP;
    TB0CTL = TBSSEL__TBCLK + MC__CONTINUOUS + TBIE;
}
// -----------------------------------------------------------------------------
void hil_initTimerA0(void)
{
    // Setup time_A0 for timestamping
    TA0CTL = MC__STOP;                                  // STOP Timer
    TA0CTL = ID__8 + TASSEL__SMCLK;                     // Timer_A0 source:SMCLK/8 = 20 / 8 = 2.500 MHz = 1/400ns
    TA0EX0 = 1;                                         // Timer_A0 set additional divider to /2
    TA0CTL |= TACLR + MC__CONTINOUS + TAIE;             // START the timer in free-running mode
}
So these are the inits for the pulse counting timer and the timestamping timer. I can figure the timestamping timer is 2.5MHz, but what is the timebase for the pulse timer?
there is this calibration function in FetDcdc.c which does use TB0R
#ifdef MSP_FET
    #define PULSES TB0R
#else
    #define PULSES TA2R
#endif

    if(_fetType == eZ_FET_WITH_DCDC_NO_FLOWCTL || _fetType == eZ_FET_WITH_DCDC ||_fetType == MSP_FET_WITH_DCDC
       || _fetType == MSP_FET_WITH_DCDC_V2x ||  _fetType == eZ_FET_WITH_DCDC_V2x)
    {
        _DINT_FET();

        for(i = 0; i < count; ++i)
        {
            TA0CTL |= TACLR + MC__CONTINOUS + TAIE; // START the timer in free-running mode

            i0 = PULSES;
            t0 = TA0R;

            // Sample VCCout
            ADC12CTL0  &= ~ADC12ENC;              // Disable conversion, write controls
            ADC12MCTL0  = ADC12SREF_1 + 1;        // select Vref and analog channel Ax
            ADC12CTL0  |= ADC12ENC;               // Enable conversions

            ADC12IFG &= ~BIT0;
            ADC12CTL0  |= ADC12SC;                // Start conversions
            while ((ADC12IFG & BIT0) == 0);       // wait until conversion is done
            ADC12IFG &= ~BIT0;

            // Wait for some time
            for(volatile unsigned long j = 0; j < DELAYCOUNT; ++j);

            i1 = PULSES;
            t1 = TA0R;

            *time += (t1 - t0);
            *ticks += (i1 - i0);
        }
        _EINT_FET();
    }
}
also line 194:
        //Configure port mapper and P2 for current measuring
        P2DIR &= ~BIT0;
        P2SEL |= BIT0;
        _DINT_FET();
        PMAPKEYID = PMAPKEY;
        PMAPCTL |= PMAPRECFG;
        P2MAP0 = PM_TB0CLK;
        PMAPKEYID = 0;
        _EINT_FET();

        dcdc_SetVcc(3300);
there is this in stream.c, not sure if it is the same timer B0
#pragma vector=TIMER2_A0_VECTOR
__interrupt void TIMER2_A0_ISR(void)
{
    if(STREAM_getSharedVariable(ID_SHARED_MEMORY_TYPE_TIMER_TICK, &TimerTick))
    {
        (*(unsigned short*)TimerTick)++;
    }
}
#pragma vector=TIMER0_B1_VECTOR
__interrupt void TIMER0_B1_ISR_(void)
{
    switch (__even_in_range(TB0IV, TB0IV_TB0IFG))
   {
       case TB0IV_TB0IFG:
           if(STREAM_getSharedVariable(ID_SHARED_MEMORY_TYPE_I_TICK, &ITick))
           {
               ++(*(unsigned short*)ITick);
           }
           break;
       default:
           break;
   }
}
So, i wonder which method is used to measure pulses, is it counting the time between pulses? 
as for the why, i integrated the energytrace dcdc into a test board, for energy budget evaluation, and thus i want to read the pulses correctly from the instrumentation MCU.
The DCDC part with the MSP430G2452 is working perfectly fine and i even added a 12bit i2c DAC as voltage reference so i can control the target VCC, all i2c commands work perfectly fine and the DCDC perfoms as it should. So now i have to count the pulses correctly and extract the datas from here.
IF anyone has a clue, any information will be helpfful.

**Attention** This is a public forum