再分享一个相关的
- // MSP430i20xx Demo - PMM Module, Compare VMONIN to Internal 1.16V, VMON ISR
- //
- // Description: Setup VMON to compare input from VMONIN to internally generated
- // 1.16V source. If VMONIN drifts below 1.16V, clear the LED. If VMONIN drifts
- // above 1.16V, turn the LED on.
- //
- // ACLK = 32kHz, MCLK = SMCLK = Calibrated DCO = 16.384MHz
- // * Ensure low_level_init.c is included when building/running this example *
- //
- // MSP430i20xx
- // -----------------
- // /|\| |
- // | | |
- // --|RST P2.3|<-- VMONIN
- // | P1.4|--> LED
- // | |
- //
- // T. Witt
- // Texas Instruments, Inc
- // September 2013
- // Built with Code Composer Studio v5.5
- //******************************************************************************
- #include "msp430.h"
- void main(void) {
- WDTCTL = WDTPW | WDTHOLD; // Stop WDT
- // Setup P1.4 for LED
- P1DIR |= BIT4; // LED Output
- P1OUT &= ~BIT4; // LED Off
- VCMONCTL |= VMONLVL_7; // Compare VMONIN to 1.16V
- VCMONCTL |= VMONIE; // Enable VMON interrupt
- // When started up, VMON requires a settling time of 0.5us
- __delay_cycles(10); // MCLK = ~16MHz; 1 cycle = ~0.0625us
- // Setup P2.3 for VMONIN
- P2SEL0 |= BIT3;
- P2SEL1 |= BIT3;
- __bis_SR_register(GIE); // Enable Interrupts
- while (1) {
- P1OUT |= BIT4; // VMONIN > 1.16V, LED On
- }
- }
- #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
- #pragma vector=VMON_VECTOR
- __interrupt void VMON_ISR(void) {
- #elif defined(__GNUC__)
- void __attribute__ ((interrupt(VMON_VECTOR))) VMON_ISR (void)
- #else
- #error Compiler not supported!
- #endif
- P1OUT &= ~BIT4; // VMONIN < 1.16V, LED Off
- }
|