使用MSP430F5255单片机,外围电路全部没有焊接,只接了晶振和外部滤波电容。系统使用的是外部晶振12M,所有IO口配置为输出,并且拉低。进入LPM3模式,测得的电流有350uA,和datasheet里面说的25uA差了10倍,请问是什么问题?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
使用MSP430F5255单片机,外围电路全部没有焊接,只接了晶振和外部滤波电容。系统使用的是外部晶振12M,所有IO口配置为输出,并且拉低。进入LPM3模式,测得的电流有350uA,和datasheet里面说的25uA差了10倍,请问是什么问题?
/* --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--*/
//******************************************************************************
// MSP430x552x Demo - Enters LPM3 with ACLK = LFXT1, REF0 disabled,
// VUSB LDO and SLDO disabled, SVS disabled
//
// Description: Configure ACLK = LFXT1 and enters LPM3. Measure current.
// ACLK = LFXT1 = 32kHz, MCLK = SMCLK = default DCO
//
// MSP430F552x
// -----------------
// /|\ | XIN|-
// | | | 32kHz
// ---|RST XOUT|-
// | |
//
// Bhargavi Nisarga
// Texas Instruments Inc.
// April 2009
// Built with CCSv4 and IAR Embedded Workbench Version: 4.21
//******************************************************************************
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
// Enable XT1
P5SEL |= BIT4+BIT5; // Port select XT1
UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
// Loop until XT1 & DCO stabilizes
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
// Port Configuration
P1OUT = 0x00;P2OUT = 0x00;P3OUT = 0x00;P4OUT = 0x00;P5OUT = 0x00;P6OUT = 0x00;
P7OUT = 0x00;P8OUT = 0x00;PJOUT = 0x00;
P1DIR = 0xFF;P2DIR = 0xFF;P3DIR = 0xFF;P4DIR = 0xFF;P5DIR = 0xFF;P6DIR = 0xFF;
P7DIR = 0xFF;P8DIR = 0xFF;PJDIR = 0xFF;
// Disable VUSB LDO and SLDO
USBKEYPID = 0x9628; // set USB KEYandPID to 0x9628
// access to USB config registers enabled
USBPWRCTL &= ~(SLDOEN+VUSBEN); // Disable the VUSB LDO and the SLDO
USBKEYPID = 0x9600; // access to USB config registers disabled
// Disable SVS
PMMCTL0_H = PMMPW_H; // PMM Password
SVSMHCTL &= ~(SVMHE+SVSHE); // Disable High side SVS
SVSMLCTL &= ~(SVMLE+SVSLE); // Disable Low side SVS
__bis_SR_register(LPM3_bits); // Enter LPM3
__no_operation(); // For debugger
}
用你的代码试了,测试电流有20mA。下面是我自己配置的代码。测试的是350uA。
//外部晶振12M
void SystemInit(void)
{
__delay_cycles(5000);
P5SEL |= BIT2 + BIT3;
UCSCTL6 &= ~XT2OFF;
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (UCSCTL7 & XT2OFFG); // Test oscillator fault flag
UCSCTL6 &= ~(XT2DRIVE_2);
UCSCTL6 |= XT2DRIVE_1;
UCSCTL4 |= SELM__XT2CLK + SELS__XT2CLK + SELA__REFOCLK;
}
void GPIO_Init(void)
{
P1DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
P2DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
P3DIR |= BIT0+BIT1+BIT2+BIT3+BIT4;
P4DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
P6DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
P7DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5;
PJDIR |= BIT0+BIT1+BIT2+BIT3;
P1OUT &= ~(BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7);
P2OUT &= ~(BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7);
P3OUT &= ~(BIT0+BIT1+BIT2+BIT3+BIT4);
P4OUT &= ~(BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7);
P6OUT &= ~(BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7);
P7OUT &= ~(BIT0+BIT1+BIT2+BIT3+BIT4+BIT5);
PJOUT &= ~(BIT0+BIT1+BIT2+BIT3);
}
void Bsp_Init(void)
{
SystemInit();
GPIO_Init();
_EINT();
}
void main( void )
{
Bsp_Init();
__bis_SR_register(LPM3_bits);
while(1);
}