Part Number:MSP430G2553
Hi!
I'm having an issue with LPM3 in a battery powered application.
We have a remote that sends radio commands with CC1101. There is a "Sleep" function between the "sendings"
and after waking up from LPM3, the remote sends slowly, ruining some time-dependant communication operations.
I checked all the BCS, TIMERA and SR registers, it seems all the same. I tried to set the clock again but the problem won't disappear.
Do you have a clue? Details below.
Thanks in advance,
Mirco
This is the send function
for(ikj=0;ikj<4;ikj++)//Send message n times { FLUSH_TX sleepII(TWNTH_SEC); RFSendPacket(txBuffer, tx_length, (char)0); // Send value over RF sleepII(TWNTH_SEC); L_SIGN_PORT_OUT ^= L_SIGN; }
This is the "sleepII"
void sleepII(unsigned int time) { BCSCTL1 |= DIVA_0; // ACLK/2 BCSCTL3 |= LFXT1S_2; // ACLK = VLO WDTCTL = WDT_ADLY_1000; // Interval timer TA0CCR0 = time; TA0CTL = MC_1+TACLR+TASSEL_1; TA0CCTL0 &= ~(CAP+CCIFG); TA0CCTL0 |= CCIE; Stop_Wait=1; __bis_SR_register(GIE); while(Stop_Wait); // __bis_SR_register(LPM0_bits+GIE); }
this is the part where enters and exits lpm3
while(TLC_Power==LOW) { P1DIR = 0xFF; // All P1.x outputs P1OUT = 0; // All P1.x reset P2DIR = 0xFF; // All P2.x outputs P2OUT = 0; // All P2.x reset ADC10CTL0 &= ~ENC; ADC10CTL0 &= ~REFON ; ADC10CTL0 &= ~ADC10ON; sleep_s(IDLE_DELAY_INFO); //__bis_SR_register(LPM3_bits), sleep_s enters lpm3 mode sleepII(CENT_SEC); if (check_button_x(1,2)) // if button pressed, wake up { TLC_Power=HIGH; // Power Flag Deep_sleep_counter=DEEP_SLEEP_DELAY; //Set_Up_Clock_and_WDT(); // it doesn't remove the problem go_to_sleep_ok=0; TLC_Power=HIGH; // Power Flag Battery_Check_time=25; // Tempo prima del prossimo battery check }
then we have sleep_s():
void sleep_s(unsigned int time) { BCSCTL1 |= DIVA_1; // ACLK/2 BCSCTL3 |= LFXT1S_2; // ACLK = VLO WDTCTL = WDT_ADLY_1000; // Interval timer TA0CCR0 = time; TA0CTL = MC_0+TACLR+TASSEL_1; TA0CCTL0 &= ~(CAP+CCIFG); TA0CCTL0 |= CCIE; __bis_SR_register(LPM3_bits+GIE); }
and TA0 ISR that exits lpm3
#pragma vector = TIMER0_A0_VECTOR __interrupt void Timer0_A0 (void) { TA0CTL &= ~(MC_1); TA0CCTL0 &= ~(CCIE); __bic_SR_register_on_exit(LPM3_bits); // __bic_SR_register_on_exit(LPM3_bits) Stop=0; Stop_Wait=0; }
the clock is calibrated with this function
void Set_Up_Clock_and_WDT(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT if (CALBC1_1MHZ==0xFF)while(1);// If calibration constant erased do not load, trap CPU!! DCOCTL = 0; // Select lowest DCOx and MODx settings BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz DCOCTL = CALDCO_1MHZ; BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO }