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

msp430x20x2 adc10 temp

3 193 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 14,01 KB

Nội dung

//****************************************************************************** // MSP430F20x2 Demo - ADC10, Sample A10 Temp and Convert to oC and oF // // Description: A single sample is made on A10 with reference to internal // 1.5V Vref Software sets ADC10SC to start sample and conversion - ADC10SC // automatically cleared at EOC ADC10 internal oscillator/4 times sample // (64x) and conversion In Mainloop MSP430 waits in LPM0 to save power until // ADC10 conversion complete, ADC10_ISR will force exit from any LPMx in // Mainloop on reti Temperaure in oC stored in IntDegC, oF in IntDegF // Uncalibrated temperature measured from device to device will vary with // slope and offset - please see datasheet // ACLK = n/a, MCLK = SMCLK = default DCO ~1.2MHz, ADC10CLK = ADC10OSC/4 // // // MSP430F20x2 - // /|\| // || | // |RST XOUT|- // | // |A10 XIN|- | | // // L Westlund // Texas Instruments Inc // May 2006 // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A //****************************************************************************** #include "msp430x20x2.h" long temp; long IntDegF; long IntDegC; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT ADC10CTL1 = INCH_10 + ADC10DIV_3; // Temp Sensor ADC10CLK/4 ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE; enable_interrupt(); TACCR0 = 30; TACCTL0 |= CCIE; // Enable interrupts // Delay to allow Ref to settle // Compare-mode interrupt TACTL = TASSEL_2 | MC_1; LPM0; // TACLK = SMCLK, Up mode // Wait for delay TACCTL0 &= ~CCIE; // Disable timer Interrupt disable_interrupt(); while(1) { ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled // oF = ((A10/1024)*1500mV)-923mV)*1/1.97mV = A10*761/1024 - 468 temp = ADC10MEM; IntDegF = ((temp - 630) * 761) / 1024; // oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278 temp = ADC10MEM; IntDegC = ((temp - 673) * 423) / 1024; no_operation(); // SET BREAKPOINT HERE } } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR interrupt void ADC10_ISR (void) { bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR) } #pragma vector=TIMERA0_VECTOR interrupt void ta0_isr(void) { TACTL = 0; LPM0_EXIT; } // Exit LPM0 on return ... #include "msp430x20x2. h" long temp; long IntDegF; long IntDegC; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT ADC10CTL1 = INCH_10 + ADC10DIV_3; // Temp Sensor ADC10CLK/4 ADC10CTL0 =... A10*761/1024 - 468 temp = ADC10MEM; IntDegF = ( (temp - 630) * 761) / 1024; // oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278 temp = ADC10MEM; IntDegC = ( (temp - 673) * 423) / 1024;... ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled // oF = ((A10/1024)*1500mV)-923mV)*1/1.97mV = A10*761/1024 - 468 temp

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

TỪ KHÓA LIÊN QUAN

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

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w