Other Parts Discussed in Thread: ENERGYTRACE
Hello All!
Would really appreciate your help in this. I've been very confused for about 4 days on this problem now. Re-read all documents and no luck.
I have following requirements:
*Simple IoT sensor application.
*Wake up MSPFR2311 every ~5s, communicate with sensor for ~5ms through I2C, back to sleep.
*Every 1hr transmit through SPI to wireless chip for ~50 ms and back to sleep.
*Battery life is critical, which is why I am trying to use LPM4 to sleep for ~5s (timing not critical in slightest).
However, the issue I am seeing is that the CPU is awake for far too long. I am very very confused as I have timed with GPIOs all available code and it runs much shorter then the power draw. My ISR runs for ~30 uS and code runs at max for ~50ms. However current measurements with EnergyTrace reports that my activemode current is way too long (and variable too!) It's sometimes as long as a full second somehow.
I narrowed my program to do the minimum possible that still repros this on at least 2 boards.
#include "io430.h" int main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; //set pins to low power mode. P1OUT = 0x00; P2OUT = 0x00; P1DIR = 0xFF; P2DIR = 0xFF; //unlock pins PM5CTL0 &= ~LOCKLPM5; //set RTC to trigger ~8 seconds RTCMOD = 10000UL; RTCCTL = RTCSS_3 | RTCSR | RTCPS_1 | RTCIE; while(1) { //pretend to do work for 5000 / 2MHz = 2.5 mS unsigned volatile long wait_var = 5000; while(wait_var>1) wait_var--; __bis_SR_register(LPM4_bits | GIE); } return 0; } #pragma vector=RTC_VECTOR __interrupt void RTC_ISR(void) { (void)RTCIV; //clear interrupt __bic_SR_register_on_exit(LPM4_bits); //return to main program return; }
Here is the energy trace showing mysterious long delays everywhere. How could this?