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

MSP430低功耗问题

工程师:

         你好,本人调试MSP430F5310的程序发现一个问题,不知道怎么解决,麻烦工程师给我指点一下。

        刚开始,我将CPU的所有的IO口,都配置为输出,低电平,CPU为LPM3模式,此时利用万用表测得板子电流为7.4uA,这个电流我认为正常的;但是当我在这个基础上开启定时器后,定时器中断内部不做任何运算,只是为了进入中断,此时我测得的电流是54uA。我想问的是,CPU是LPM3模式,只是开启了定时器,为什么电流升高了这么多。(附程序)

#include <msp430.h>

#define SYS14_WORKAROUND // Comment this line if silicon revision has SYS14 bug fixed
#ifdef SYS14_WORKAROUND
#define INIT_MEMORY_ADDR 0x0900
unsigned int *Address = ((unsigned int*)INIT_MEMORY_ADDR);#endif

void Peripheral_Init(void)
{
/* USER CODE START (section: GPIO_graceInit_prologue) */
/* User initialization code */
/* USER CODE END (section: GPIO_graceInit_prologue) */

P1OUT = 0; //P1端口初始化
P1IES = 0;
P1IFG = 0;
#if PIN_MODE == 0 //上一版程序端口设置
/* Port 1 Direction Register */
P1DIR = BIT3 | BIT4 | BIT7;
/* Port 1 Interrupt Edge Select Register */
P1IES = 0;
/* Port 1 Interrupt Flag Register */
P1IFG = 0;
#else //这版程序端口设置
/* Port 1 Direction Register */
P1DIR &= ~(BIT6 | BIT7); //设置为输入 //CC1101的二个引脚

P1DIR &= ~(BIT0 | BIT1); //设置为输入 //运动传感器中断引脚
//P1REN |= (BIT0 | BIT1); //使能上下拉电阻
P1IES &= ~BIT1; //一个低电平到高电平转换 //上升沿 中断设置
P1IES &= ~BIT7; //一个低电平到高电平转换 P1REN |= (BIT6 | BIT7|BIT0 | BIT1);
P1IE = 0x00; //先关闭所所有IO中断

#endif
/* Port 4 Output Register */
P4OUT = 0;
/* Port 4 Direction Register */
P4DIR = 0;
/* 分压电阻通断IO口初始化 */
P4DIR |= BIT6|BIT7; //设置为输出 P4OUT &= ~(BIT6|BIT7);

/* **************************
*MCLK=DCO=8MHZ
*ACLK=XF1=32768HZ
*SMCLK=DCO=8MHZ
*****************************/
P5SEL |= BIT4|BIT5; // Select XT1

UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
UCSCTL3 = SELREF_2; // Set DCO FLL reference = REFO // Loop until XT1,XT2 & DCO stabilizes – In this case loop until XT1 and DCo settle
do
{
UCSCTL7 &= ~(XT2OFFG | XT1LFOFFG | DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL6 &= ~(XT1DRIVE_3); // Xtal is now stable, reduce drive strength

UCSCTL4 |= SELA_0; // ACLK = LFTX1 (by default)
__bis_SR_register(SCG0); // Disable the FLL control loop
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_5; // Set RSELx for DCO = 8MHz
UCSCTL2 |= 243; // Set DCO Multiplier for 8MHz
// (N + 1) * FLLRef = Fdco
// (243 + 1) * 32768 = 8MHz
__bic_SR_register(SCG0); // Enable the FLL control loop
__delay_cycles(250000);
/* USER CODE START (section: System_graceInit_epilogue) */
/* User code */
/* USER CODE END (section: System_graceInit_epilogue) */
__bis_SR_register(GIE);
#if CS_PIN_MODE == 1U // 上个版本的程序
//cc1101 -> P3.6 adxl362 -> P3.3
P3DIR |= (BIT3 | BIT6);
P3REN |= (BIT3 | BIT6);#endif
#if CS_PIN_MODE == 2U // 这个版本SPI的配置

//cc1101 -> P3.2 adxl362 -> P3.3
P4DIR |= (BIT2 | BIT3);
P4REN |= (BIT2 | BIT3);#endif
#if SPI_MODE == SPI_HARDWARE // 这个个版本的程序spi配置

/* Port 3 Port Select Register */
P4SEL |= (BIT0 | BIT4 | BIT5);
//P3.1 -> GDO0 P3.2 -> GDO2
P4OUT |= (BIT1 | BIT2); //设置上拉电阻
P4DIR &= ~(BIT1 | BIT2); //设置为输入
P4REN |= (BIT1 | BIT2);
/* Disable USCI */
UCA1CTL1 |= UCSWRST;

/* * Control Register 0
* * UCCKPH — Data is captured on the first UCLK edge and changed on the following edge
* ~UCCKPL — Inactive state is low
* UCMSB — MSB first
* ~UC7BIT — 8-bit
* UCMST — Master mode
* UCMODE_0 — 3-Pin SPI
* UCSYNC — Synchronous Mode
* * Note: ~<BIT> indicates that <BIT> has value zero
*/
UCA1CTL0 = UCCKPH | UCMSB | UCMST | UCMODE_0 | UCSYNC;
//UCA0CTL0 = UCCKPL | UCMSB | UCMST | UCMODE_0 | UCSYNC;
/* * Control Register 1
* * UCSSEL_2 — SMCLK
* UCSWRST — Enabled. USCI logic held in reset state
*/
UCA1CTL1 = UCSSEL_2 | UCSWRST;
#if SPI_CLOCK_PERIOD == SPI_CLK_100K
UCA1BR0 = 80; //100kbps#elif SPI_CLOCK_PERIOD == SPI_CLK_256K
UCA1BR0 = 32; //256kbps
#elif SPI_CLOCK_PERIOD == SPI_CLK_500K
UCA1BR0 = 16; //500kbps
#elif SPI_CLOCK_PERIOD == SPI_CLK_1000K
UCA1BR0 = 8; //500kbps
#elif SPI_CLOCK_PERIOD == SPI_CLK_2000K
UCA1BR0 = 4; //2000kbps
#endif

/* DISEnable USCI */
UCA1CTL1 &= ~UCSWRST;
// **Initialize USCI state machine**
/* USER CODE START (section: USCI_A1_graceInit_epilogue) */
/* User code */
/* USER CODE END (section: USCI_A1_graceInit_epilogue) */
#elif SPI_MODE == SPI_SOFTWARE //上个版本的程序
//P3.4 -> mosi P3.5 -> miso P3.0 -> sck
P3OUT |= (BIT0 | BIT4 | BIT5); //设置上拉电阻
P3DIR &= ~(BIT5); //设置为输入
P3DIR |= (BIT0 | BIT4); //设置为输出
P3REN |= (BIT0 | BIT4 | BIT5);#endif
P2DIR |= BIT0;
P2OUT |= BIT0;
P2IFG = 0;
}

void init_time(void)
{
TA0CCR0 = 320; TA0CTL &= (~0x300); // 0000 0011 0000 0000 0x0300
TA0CTL |= TASSEL_1;
TA0CTL |= ID_0;

TA0CCTL0 |= CCIE;
TA0CTL|= MC_1|TACLR; // Start timer in up mode
}

int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
#ifdef SYS14_WORKAROUND *Address = 0x9628;
*(Address+4) = 0x0800;
*Address = 0x9600;#endif Peripheral_Init();
init_time();
P1OUT = 0x00;P2OUT = 0x00;P3OUT = 0x00;P4OUT = 0x80;P5OUT = 0x00;P6OUT = 0x00;
PJOUT = 0x00; // Port Configuration
P1DIR = 0xFF;P2DIR = 0xFF;P3DIR = 0xFF;P4DIR = 0xFF;P5DIR = 0xFF;P6DIR = 0xFF;
PJDIR = 0xFF; // Disable SVS
while(1)
LPM3;
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void)
{
TA0CTL |= TACLR;
_NOP();
//Adc10Start();
}

灰小子:

你的程序不止用到了定时器,还使用了外部8MHz晶振,用到了smclk。

估计也没真正进入LPM3

这些都是功耗

user4234806:

回复 灰小子:

在没用开定时之前,我已经开了8MH在,还有SMCLK测得电流是7.4uA,开了定时器电流变成50多uA。并且我在线调试程序进入LPM3

Ling Zhu2:

回复 user4234806:

guang dong hu

在没用开定时之前,我已经开了8MH在,还有SMCLK测得电流是7.4uA,开了定时器电流变成50多uA。并且我在线调试程序进入LPM3

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