通过RTC中断1S唤醒
void main(void)
{
WM_Initialize(); // System initialize
// Display "123456"
LCD_Display0_8();
while(1)
{
__bis_SR_register(LPM3_bits + GIE); // 进入 LPM3 w/ interrupt
}
}
void WM_Initialize(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog
// WDTCTL = WDTPW + WDTCNTCL + WDTSSEL0 + WDTIS0 + WDTIS1; // Set watchdog 16s
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
GPIO_Config(); // GPIO initialize
CLOCK_Config(); // System clock initialize
LCD_Config(); // LCD module initialize
RTC_Config();
//P1SEL0 |= BIT5; //配置P15为输入脚 20160506
// P1REN |= BIT5;
//P1REN &= ~BIT5; // to be comment 20160506
//TA0CTL = 0; 20160506
}
void CLOCK_Config()
{
P4SEL0 |= BIT1 + BIT2; // Select pin4.1 pin4.2 as crystal function
do
{
CSCTL7 &= ~(XT1OFFG + DCOFFG); // Clear XT1 and DCO fault flag 清除 XT1 DCO 失效标志
SFRIFG1 &= ~OFIFG;
}while (SFRIFG1 & OFIFG); // Test oscillator fault flag 如果失效标志存在
CSCTL4 = SELA__XT1CLK; // IMPORTANT. Select ACLK = XT1 = 32768Hz
}
void LCD_Config()
{
uint8_t ui8Cnt;
uint8_t *pLCD = (uint8_t *)&LCDM0;
for (ui8Cnt = 13; ui8Cnt > 0; ui8Cnt--) // Clear LCD memory
*pLCD++ = 0x00; // CLR LCD
SYSCFG2 |= LCDPCTL; // R13/R23/R33/LCDC1/LCDC2 pins selected 设置 LCD功耗
LCDPCTL0 = 0xFFFF;
LCDPCTL1 = 0x01FF; //设置 LCD管脚 L0~L24 pins selected
LCDVCTL = LCDSELVDD + LCDCPEN; // Mode 2 设置 降低LCD 功耗 片上电荷泵
LCDCSSEL0 = 0x000F; // 设置 公共极 COM0~3
LCDCSSEL1 = 0x0000;
LCDM0 = 0x21; // L0 = COM0, L1 = COM1
LCDM1 = 0x84;
LCDCTL0 |= LCD4MUX + LCDLP + LCDON; // 打开LCD: 4-mux 模式
}
void RTC_Config()
{
RTCCTL = RTCSS__XT1CLK + RTCSR + RTCPS__1 | RTCIE;
RTCMOD = 32768-1; //1s
tRTCData.ui8Year = 14; // RTC initialize
tRTCData.ui8Month = 7;
tRTCData.ui8Day = 30;
tRTCData.ui8Hour = 23;
tRTCData.ui8Minute = 59;
tRTCData.ui8Second = 55;
}
// RTC interrupt service routine
#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR(void)
{
switch(__even_in_range(RTCIV,RTCIV_RTCIF))
{
case RTCIV_NONE: break; // No interrupt
case RTCIV_RTCIF: // RTC Overflow
{
uint8_t ui8Days = 31;
uint8_t *pAddress; // For monthly data storage
tRTCData.ui8Second++;
。。。
__low_power_mode_off_on_exit(); //退出中断时唤醒CPU
}
break;
default: break;
}
}
要看你的外围器件了,单片机用20mA基本不太可能。
主要原因找到,是I/O口设置问题MSP430FR4133
现在LMP3模式下在80uA
正常吗?
本帖最后由 QIHAO74 于 2016-5-16 16:12 编辑
先告诉你,别问问题贴一堆的程序上来,看的心烦。感觉你没动脑子,把AD内部比较电压关了再试。单片机资源你一个个关。
查出来,外部参考电压,改用内部参考电压,现在功耗是 19UA到7UA跳变
平常只开RTC,1秒钟定时,LPM3,只在外部中断才唤醒。
这样正常吗?
我这边测试的代码中 PM5CTL0 &= ~LOCKLPM5影响到静态功耗,如果没有,则很方便进入低功耗休眠模式
您可以试试