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

msp430g2x32 adc10 03

2 136 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 2
Dung lượng 2,92 KB

Nội dung

//****************************************************************************** // MSP430G2x32/G2x52 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 // // MSP430G2x32/G2x52 // // /|\| XIN|// | | | // |RST XOUT|// | | // |A10 P1.0| >LED // // D Dang // Texas Instruments Inc // December 2010 // Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10 //****************************************************************************** #include "msp430g2452.h" static unsigned int FirstADCVal; // holds 1st ADC result #define ADCDeltaOn // ~ 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(); // Enable interrupts TACCR0 = 30; // Delay to allow Ref to settle TACCTL0 |= CCIE; // Compare-mode interrupt TACTL = TASSEL_2 | MC_1; // TACLK = SMCLK, Up mode LPM0; // Wait for delay TACCTL0 &= ~CCIE; // 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)); // First conversion? FirstADCVal = ADC10MEM; // Read out 1st ADC value P1OUT = 0x00; // 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 off } #pragma vector=TIMER0_A0_VECTOR interrupt void ta0_isr(void) { TACTL = 0; LPM0_EXIT; } // Exit LPM0 on return

Ngày đăng: 26/12/2017, 07:50

TỪ KHÓA LIÊN QUAN

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

TÀI LIỆU LIÊN QUAN

w