1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

msp430x20x2 adc10 03

3 118 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 3
Dung lượng 13,99 KB

Nội dung

//****************************************************************************** // MSP430F20x2 Demo - ADC10, Sample A10 Temp, Set P1.0 if Temp ++ ~2C // // Description: se ADC10 and the integrated temperature sensor to detect // temperature gradients The temperature sensor output voltage is sampled // ~ every 120ms and compared with the defined delta values using an ISR // (ADC10OSC/4)/64 determines sample time which needs to be greater than // 30us for temperature sensor // ADC10 is operated in repeat-single channel mode with the sample and // convert trigger sourced from Timer_A CCR1 The ADC10IFG at the end // of each converstion will trigger an ISR // ACLK = n/a, MCLK = SMCLK = default DCO ~ 1.2MHz, ADC10CLK = ADC10OSC // // // MSP430F20x2 - // /|\| XIN|- // || | // |RST XOUT|- // | | // |A10 P1.0| >LED // // L Westlund // Texas Instruments Inc // May 2006 // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A //****************************************************************************** #include "msp430x20x2.h" static unsigned int FirstADCVal; #define ADCDeltaOn // holds 1st ADC result // ~ Deg C delta for LED on void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog ADC10CTL1 = ADC10DIV_3 + INCH_10 + SHS_1 + CONSEQ_2; // TA trig., rpt, A10 ADC10CTL0 = SREF_1 + ADC10SHT_3 + REF2_5V + ADC10IE + REFON + ADC10ON; enable_interrupt(); TACCR0 = 30; TACCTL0 |= CCIE; // Enable interrupts // Delay to allow Ref to settle // Compare-mode interrupt TACTL = TASSEL_2 | MC_1; LPM0; TACCTL0 &= ~CCIE; // TACLK = SMCLK, Up mode // Wait for delay // Disable timer Interrupt disable_interrupt(); ADC10CTL0 |= ENC; TACCTL1 = OUTMOD_4; // Toggle on EQU1 (TAR = 0) TACTL = TASSEL_2 + MC_2; // SMCLK, cont-mode while (!(ADC10IFG & ADC10CTL0)); FirstADCVal = ADC10MEM; P1OUT = 0x00; // First conversion? // Read out 1st ADC value // Clear P1 P1DIR = 0x01; // P1.0 as output bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } #pragma vector=ADC10_VECTOR interrupt void ADC10_ISR (void) { if (ADC10MEM >= FirstADCVal + ADCDeltaOn) P1OUT |= 0x01; // LED on else P1OUT &= ~0x01; // LED of } #pragma vector=TIMERA0_VECTOR interrupt void ta0_isr(void) { TACTL = 0; LPM0_EXIT; } // Exit LPM0 on return

Ngày đăng: 25/12/2017, 11:24

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w