变态测试msp430G2452低功耗LPM3模式下不同CPU主频的功耗试验
虽然大多数情况下msp430应用于电池供电很有优势,一般较低电压时只能低主频,但是也是有不需要考虑低电压但又要考虑功耗的情况吧?那么这时候我们选择高一点cpu主频好还是低一点的好呢?
本实验以1MHz和8MHz的不同MCLK为例
测试程序如下:
- //测试msp430G2452低功耗LPM3模式下不同CPU主频的功耗
- #include "io430.h"
- volatile unsigned char buttonTimes;
- void main( void )
- {
- WDTCTL = WDTPW + WDTHOLD;
-
- P1OUT = BIT3;//+BIT4;
- P1DIR = BIT0 + BIT1 + BIT2 + BIT4 + BIT5 + BIT6;
- P1REN = BIT3;
- P1IES = 0;
- P1IFG = 0;
- P1IE=BIT3+BIT7;
-
- P2DIR=0xFF;
-
- BCSCTL2 = SELM_0 + DIVM_0 + DIVS_0;
- if (CALBC1_1MHZ != 0xFF) {
- DCOCTL = 0x00;
- BCSCTL1 = CALBC1_1MHZ; /* Set DCO to 1MHz */
- DCOCTL = CALDCO_1MHZ;
- }
- BCSCTL1 |= XT2OFF + DIVA_0;
- BCSCTL3 = XT2S_0 + LFXT1S_0 + XCAP_3;
- do
- {
- IFG1 &= ~OFIFG;
- __delay_cycles(50);
- } while (IFG1 & OFIFG);
-
- buttonTimes=1;
- TACCR0 = 63;
- TACCTL0=CCIE;
- TACTL = TASSEL_1 + ID_0 + MC_1;
- __bis_SR_register(GIE);
-
- while(1)
- {
- LPM3;
- P1OUT^=BIT0;
- __delay_cycles(1000);
- }
- }
- #pragma vector=PORT1_VECTOR
- __interrupt void PORT1_ISR_HOOK(void)
- {
- P1IFG=0;
- if(buttonTimes)
- {
- buttonTimes=0;
- DCOCTL = 0x00;
- BCSCTL1 = CALBC1_8MHZ; /* Set DCO to 1MHz */
- DCOCTL = CALDCO_8MHZ;
- }
- else
- {
- buttonTimes=1;
- DCOCTL = 0x00;
- BCSCTL1 = CALBC1_1MHZ; /* Set DCO to 1MHz */
- DCOCTL = CALDCO_1MHZ;
-
- }
- }
- #pragma vector=TIMER0_A0_VECTOR
- __interrupt void TIMER0_A0_ISR_HOOK(void)
- {
- LPM3_EXIT;
- }
复制代码如有错误望指正
初步试验结果,好像使用LPM3模式还是高主频省电
视频按键操作方向没有摄像进来,开始短可以看到LaunchPad上跨接有带2M电阻的导线,还有另一条导线接地,用来碰触带电阻的导线实现按键,有点懒,应该增加按键延时处理程序的,哪位有兴趣补写一段我再来试验一下。
[
本帖最后由 wangfuchong 于 2013-2-20 22:56 编辑 ]