TI中文支持网
TI专业的中文技术问题搜集分享网站

无法退出低功耗

各位大侠救命,遇到个问题:MSP430F5438A 进入LPM3后,在定时器中断中退出低功耗,无法进入主程序,然后就只能进入定时中断程序了,好像是退出不了低功耗模式。而且这种情况是偶然出现的。与变量太多有关吗?在初始化时在一个结构体前加了__no_init,不然初始化超时重启。

Alvin Chen:

/* --COPYRIGHT--,BSD_EX* Copyright (c) 2012, Texas Instruments Incorporated* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** *Redistributions of source code must retain the above copyright*notice, this list of conditions and the following disclaimer.** *Redistributions in binary form must reproduce the above copyright*notice, this list of conditions and the following disclaimer in the*documentation and/or other materials provided with the distribution.** *Neither the name of Texas Instruments Incorporated nor the names of*its contributors may be used to endorse or promote products derived*from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.**********************************************************************************MSP430 CODE EXAMPLE DISCLAIMER** MSP430 code examples are self-contained low-level programs that typically* demonstrate a single peripheral function or device feature in a highly* concise manner. For this the code may rely on the device's power-on default* register values and settings such as the clock configuration and care must* be taken when combining code from several examples to avoid potential side* effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware* for an API functional library-approach to peripheral configuration.** --/COPYRIGHT--*/
//******************************************************************************
//MSP430x54x Demo - Enters LPM3 (ACLK = LFXT1)
//
//Description: Configure ACLK = LFXT1 and enters LPM3. Measure current.
//ACLK = LFXT1 = 32kHz, MCLK = SMCLK = default DCO
//Note: SVS(H,L) & SVM(H,L) not disabled
//
//MSP430x5438
//-----------------
///|\ |XIN|-
//||| 32kHz
//---|RSTXOUT|-
//||
//
//W. Goh
//Texas Instruments Inc.
//April 2009
//Built with CCE Version: 3.2.2 and IAR Embedded Workbench Version: 4.11B
//******************************************************************************
#include <msp430.h>int main(void)
{WDTCTL = WDTPW+WDTHOLD;// Stop WDTP7SEL |= 0x03;// Select XT1UCSCTL6 &= ~(XT1OFF);// XT1 OnUCSCTL6 |= XCAP_3;// Internal load cap// Loop until XT1,XT2 & DCO stabilizesdo{UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);// Clear XT2,XT1,DCO fault flagsSFRIFG1 &= ~OFIFG;// Clear fault flags}while (SFRIFG1&OFIFG);// Test oscillator fault flagUCSCTL6 &= ~(XT1DRIVE_3);// Xtal is now stable, reduce drive// strengthP1OUT = 0x00;P2OUT = 0x00;P3OUT = 0x00;P4OUT = 0x00;P5OUT = 0x00;P6OUT = 0x00;P7OUT = 0x00;P8OUT = 0x00;P9OUT = 0x00;P10OUT = 0x00;P11OUT = 0x00;PJOUT = 0x00;P1DIR = 0xFF;P2DIR = 0xFF;P3DIR = 0xFF;P4DIR = 0xFF;P5DIR = 0xFF;P6DIR = 0xFF;P7DIR = 0xFF;P8DIR = 0xFF;P9DIR = 0xFF;P10DIR = 0xFF;P11DIR = 0xFF;PJDIR = 0xFF;__bis_SR_register(LPM3_bits);// Enter LPM3//可以加个延时或者用外部中断打断一下试试
LPM3_EXIT;
}

v wu:

回复 Alvin Chen:

您好,有外部中断的,也是无法退出低功耗,只能进入定时中断,您说的延时是在唤醒之前加吗?

Alvin Chen:

回复 v wu:

我说的延时是我上面那个code,就是您在进入LPM3之后加个延时在用LPM3_EXIT;

看一下这样是否可以正常退出。


v wu:

回复 Alvin Chen:

嗯嗯,我试试看,这种情况是偶尔出现,比较难验证。感谢!

v wu:

回复 Alvin Chen:

没有效果,应该不是这个原因。而且出现无法退出后,就一直退不出了,只能进入定时中断。还有别的可能吗?感谢

灰小子:

回复 v wu:

方便上传你的代码看看吗?

或者你运行一下官网的例程,看正不正常

v wu:

回复 灰小子:

void main(void)

{

   ……

__low_power_mode_3();

}

#pragma vector=TIMER0_A0_VECTOR__interrupt void Timer_A (void){

TA0CCR0 =656;

if(…)

{

__low_power_mode_off_on_exit();

}

}

#pragma vector = PORT2_VECTOR__interrupt void port2(void){

__low_power_mode_off_on_exit() ;

}

流程就是这样的,感谢

赞(0)
未经允许不得转载:TI中文支持网 » 无法退出低功耗
分享到: 更多 (0)