?? msp430dayii_lpm3.c
字號:
//******************************************************************************
// MSP-430-Day II Demo - LPM3 Using BasicTimer ISR, 32kHz ACLK
//
// Description: System runs normally in LPM3 with basic timer clocked by
// 32kHz ACLK. At a 2 second interval the basic timer ISR will wake the
// system and flash the LCD controller on/off.
// ACLK = LFXT1 = 32768, MCLK = SMCLK = DCO = 32xACLK = 1.048576MHz
// //*External watch crystal on XIN XOUT is required for ACLK*//
//
//
// MSP430FG439
// ---------------
// /|\| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// | Sx,COMx|--> /SBLCDAA softbaugh LCD/
//
// M. Buccini
// Texas Instruments, Inc
// February 2004
// Built with IAR Embedded Workbench Version: 2.21B
//******************************************************************************
#include <msp430xG43x.h>
static char *LCD = LCDMEM;
const char char_gen[] = {
0xf5, // Displays "0"
0x60, // Displays "1"
0xb6, // Displays "2"
0xf2, // Displays "3"
0x63, // Displays "4"
0xd3, // Displays "5"
0xd7, // Displays "6"
0x70, // Displays "7"
0xf7, // Displays "8"
0xf3, // Displays "9"
0x77, // Displays "A"
0x00, // Displays Blank
0x95, // Displays "C"
0x33, // Displays "degrees" o
0x97, // Displays "E"
0x17, // Displays "F"
0x08, // Displays ":" or "."
0x02, // Displays "-"
0x87 // Displays "t"
};
void main(void) {
int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP18PF; // Set load caps
P1OUT = 0x00; // P1.0 = LED, P1.2 = Sensor GND
P2OUT = 0x00;
P3OUT = 0x00;
P1DIR = 0xFB;
P2DIR = 0xF9; // P2.1/2 = Push buttons
P3DIR = 0xFF;
P6SEL |= 0xFF; // P6.x ADC option select
P5SEL = 0xFC; // Set Rxx and COM pins for LCD
LCDCTL = LCDON + LCD4MUX + LCDSG0_3; // SBLCDA4 LCD 4Mux, S0-S23
BTCTL = BT_fLCD_DIV128 + BT_ADLY_2000; // SBLCDA4 LCD freq, 2 second interrupt
IE2 |= BTIE; // Enable Basic Timer interrupt.
for( i = 0; i < 20; i++){ // Clear LCD Display RAM
LCD[i] = 0;
} // for
LCD[1] = char_gen[4]; // "4"
LCD[2] = char_gen[3]; // "3"
LCD[3] = char_gen[0]; // "0"
while (1)
{
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupts
LCDCTL ^= LCDON; // Toggle LCD on/off
} // while
} // main
// Basic Timer interrupt service routine
#pragma vector=BASICTIMER_VECTOR
__interrupt void basic_timer(void)
{
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -