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 }
#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(); } }
//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);
#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; } }