请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:MSP430FR2355 您好论坛、
我已经编写了一些简单的代码来将 MSP430fr2355置于 LPM4模式、但我在3V 时的测量值大约为60uA。这似乎比我预期的要高很多、我是否在代码中遗漏了明显的东西?
int main(void)
{
//////////////////////////////Set up the ports and variables///////////////////////////////////////////
//Stop watchdog timer
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
///PORT 6 SET UP
P6DIR = P6DIR | 0b11111111; //Set port 6 to all outputs
P6OUT = P6OUT & 0b00000000; // P6 all outputs off
///PORT 4 SET UP // Configure Pins for I2C//////////////
P4DIR = 0b11111111;
P4OUT = 0b11000000;
P4SEL0 |= BIT6 | BIT7; // I2C pins
P4SEL1 &= 0b00111111; // I2C pins
///PORT 5 SET UP
P5DIR = 0b11111111; //Port 5 all outputs - remember that port 5.1 and 5.2 have been disconnected and redirected to port 1
//P5REN = 0b11111110;
P5OUT = 0b00000000;
///PORT 3 SET UP
P3DIR = 0b11111111; //Set as all outputs and
P3OUT = 0b00000000; //Set all pins low
///PORT 2 SET UP
P2SEL0 |= 0b11000000; // Configure 6 and 7 for external clock.
P2SEL1 |= 0b11000000;
P2DIR = 0b11101111; // 6 and 7 are used for clk, 4 is used for interrupt
P2OUT = 0b00100000;
P2IE |= 0b10000; // P2.4 interrupt enabled
P2IES |= 0b00000; // P2.4 Hi/lo edge
P2IFG &=~0b10000; // P2.4 IFG cleared
///PORT 1 SET UP
//P1SEL0 |= 0b1; // Configure ADC A1 pin 0
//P1SEL1 |= 0b1;
P1DIR = 0b11111000; //Port 1 set as inputs and outputs remember that ports 1.1 and 1.2 have been connected to max interrupts
P1IE |= 0b00000110; // interrupt enabled
P1IES |= 0b00000000; // Lo/Hi edge
P1IFG &= 0b00000000; // IFG cleared
//P1OUT = 0b00000000;
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode to activate previously configured port settings
// Source = 32kHz crystal, divided by 1024
// RTCCTL = RTCSS__XT1CLK | RTCSR | RTCPS__1024 | RTCIE;
//////////////////////////Set clock to 8MHZ///////////////////////////////////
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode to activate 1previously configured port settings
__bis_SR_register(SCG0); // disable FLL
CSCTL3 |= SELREF__XT1CLK; // Set REFO as FLL reference source
CSCTL1 = DCOFTRIMEN_1 | DCOFTRIM0 | DCOFTRIM1 | DCORSEL_3;// DCOFTRIM=3, DCO Range = 8MHz
CSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz this is F3 in hex
__delay_cycles(3);
__bic_SR_register(SCG0); // enable FLL
Software_Trim(); // Software Trim to get the best DCOFTRIM value
CSCTL4 = SELMS__DCOCLKDIV | SELA__XT1CLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
// default DCODIV as MCLK and SMCLK source
PMMCTL0 = PMMPW |PMMREGOFF; // This should enable the PCMTL0 password and also turn off the internal regulator.
_low_power_mode_4(); //Should enter LPM4