//****************************************************************************** // MSP430G2x32/G2x52 Demo - ADC10, Output Internal Vref on P1.4 & ADCCLK on P1.3 // // Description: Output ADC10 internal Vref on P1.4, toggling between two // avaialble options, 2.5v and 1.5v ADC10OSC also output on P1.3 // // MSP430G2x32/G2x52 // // /|\| XIN|// | | | // |RST XOUT|// | | // Vref ADC10OSC ~ 3.5MHz - 6.5MHz // // D Dang // Texas Instruments Inc // December 2010 // Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10 //****************************************************************************** #include "msp430g2452.h" void delay(void); // Software delay void main(void) { WDTCTL = WDTPW + WDTHOLD; // ADC10CTL1 = CONSEQ_2; // ADC10CTL0 = REFOUT + REFON + MSC + ADC10ON; enable_interrupt(); // TACCR0 = 30; // TACCTL0 |= CCIE; // TACTL = TASSEL_2 | MC_1; // LPM0; // TACCTL0 &= ~CCIE; // disable_interrupt(); ADC10AE0 |= 0x10; // P1DIR |= 0x08; // P1SEL |= 0x08; // for (;;) { ADC10CTL0 &= ~ENC; ADC10CTL0 ^= REF2_5V; ADC10CTL0 |= ENC + ADC10SC; delay(); } Stop WDT Repeat single channel Enable interrupts Delay to allow Ref to settle Compare-mode interrupt TACLK = SMCLK, Up mode Wait for delay Disable timer Interrupt P1.4 ADC option select Set P1.3 output direction Set P1.3 option select // ADC10 disable // Toggle Vref 1.5/2.5V // Sampling and conversion start } void delay(void) { volatile unsigned long i; for (i = 0x7FFFF; i > 0; i ); } #pragma vector=TIMER0_A0_VECTOR interrupt void ta0_isr(void) { TACTL = 0; LPM0_EXIT; } // Exit LPM0 on return