/****CPU运行在VLO时钟下****/
#include "msp430g2553.h"
int main( void )
{
WDTCTL = WDTPW + WDTHOLD;//关闭看门狗
P1DIR = BIT6;//P1.6配置输出
P1OUT = 0;//关闭LED
BCSCTL3 |= LFXT1S_2;//LFXT1=VLO
IFG1 &= (~OFIFG);//清除OSCFault标志
__bis_SR_register(SCG1+SCG0);//关闭DCO 将SR里面的SCG1+SCG0置位
BCSCTL2 |= SELM_3+DIVM_3;
while(1)
{
P1OUT = BIT6;
__delay_cycles(100);
P1OUT = 0;
__delay_cycles(5000);
}
}
此帖出自
小平头技术问答
为什么不直接用头文件里的 LPM3;指令。。。/* Low Power Modes coded with Bits 4-7 in SR */
#ifndef __IAR_SYSTEMS_ICC__ /* Begin #defines for assembler */
#define LPM0 (CPUOFF)
#define LPM1 (SCG0+CPUOFF)
#define LPM2 (SCG1+CPUOFF)
#define LPM3 (SCG1+SCG0+CPUOFF)
#define LPM4 (SCG1+SCG0+OSCOFF+CPUOFF)
/* End #defines for assembler */
#else /* Begin #defines for C */
#define LPM0_bits (CPUOFF)
#define LPM1_bits (SCG0+CPUOFF)
#define LPM2_bits (SCG1+CPUOFF)
#define LPM3_bits (SCG1+SCG0+CPUOFF)
#define LPM4_bits (SCG1+SCG0+OSCOFF+CPUOFF)
#include "in430.h"
#define LPM0 __bis_SR_register(LPM0_bits) /* Enter Low Power Mode 0 */
#define LPM0_EXIT __bic_SR_register_on_exit(LPM0_bits) /* Exit Low Power Mode 0 */
#define LPM1 __bis_SR_register(LPM1_bits) /* Enter Low Power Mode 1 */
#define LPM1_EXIT __bic_SR_register_on_exit(LPM1_bits) /* Exit Low Power Mode 1 */
#define LPM2 __bis_SR_register(LPM2_bits) /* Enter Low Power Mode 2 */
#define LPM2_EXIT __bic_SR_register_on_exit(LPM2_bits) /* Exit Low Power Mode 2 */
#define LPM3 __bis_SR_register(LPM3_bits) /* Enter Low Power Mode 3 */
#define LPM3_EXIT __bic_SR_register_on_exit(LPM3_bits) /* Exit Low Power Mode 3 */
#define LPM4 __bis_SR_register(LPM4_bits) /* Enter Low Power Mode 4 */
#define LPM4_EXIT __bic_SR_register_on_exit(LPM4_bits) /* Exit Low Power Mode 4 */
#endif /* End #defines for C */
这是头文件里的相关定义
在IAR的msp430g2553.h里
看样子你好像少了CPUOFF
一周热门 更多>