?? msp430x24x_adc12_03.s43
字號:
;*******************************************************************************
; MSP430x24x Demo - ADC12, Sample A10 Temp, Set P1.0 if Temp ++ ~2C
;
; Description: Use ADC12 and the integrated temperature sensor to detect
; temperature gradients. The temperature sensor output voltage is sampled
; ~ every 80ms and compared with the defined delta values using an ISR.
; (ADC12OSC/256)/ determines sample time which needs to be greater than
; 30us for temperature sensor.
; ADC12 is operated in repeat-single channel mode with the sample and
; convert trigger sourced from Timer_A CCR1. The ADC12MEM0_IFG at the end
; of each conversion will trigger an ISR.
; ACLK = 32kHz, MCLK = SMCLK = default DCO 1048576Hz, ADC12CLK = ADC12OSC
;
; MSP430x24x
; -----------------
; /|\| XIN|-
; | | | 32kHz
; --|RST XOUT|-
; | |
; | P1.0|-->LED
;
;
; B. Nisarga
; Texas Instruments Inc.
; September 2007
; Built with IAR Embedded Workbench Version: 3.42A
;*******************************************************************************
#include "msp430x24x.h"
ADCDeltaOn EQU 12 ; ~ 2 Deg C delta for LED on
;-------------------------------------------------------------------------------
RSEG CSTACK ; Define stack segment
;-------------------------------------------------------------------------------
RSEG CODE ; Assemble to Flash memory
;-------------------------------------------------------------------------------
RESET mov.w #SFE(CSTACK),SP ; Initialize stackpointer
mov.w #WDTPW+WDTHOLD,WDTCTL ; Stop watchdog
mov.w #SHS_1+SHP+CONSEQ_2,&ADC12CTL1 ; TA trig., rpt conv
mov.b #SREF_1+INCH_10,&ADC12MCTL0 ; Channel A10, Vref+
bis.w #001h,&ADC12IE ; Enable ADC12IFG.0
mov.w #SHT0_8+REF2_5V+REFON+ADC12ON,&ADC12CTL0 ; Config ADC12
; Delay for Ref to settle
mov.w #13600,&TACCR0 ; Delay to allow Ref to settle
bis.w #CCIE,&TACCTL0 ; Compare-mode interrupt.
mov.w #TACLR+MC_1+TASSEL_2,&TACTL; up mode, SMCLK
bis.w #LPM0+GIE,SR ; Enter LPM0, Enable interrupts
bic.w #CCIE,&TACCTL0 ; Disable timer interrupt
dint ; Disable Interrupts
bis.w #ENC,&ADC12CTL0 ; Config ADC12
mov.w #OUTMOD_4,&TACCTL1 ; Toggle on EQU1 (TAR = 0)
mov.w #TASSEL_2+MC_2,&TACTL ; SMCLK, cont-mode
ADC_Wait bit.w #001h,&ADC12IFG ; First conversion?
jz ADC_Wait
mov.w &ADC12MEM0,R4 ; Read out 1st ADC value
add.w #ADCDeltaOn,R4 ;
clr.b &P1OUT ; Clear P5
bis.b #BIT0,&P1DIR ; P1.0 as output
;
Mainloop bis.w #LPM0+GIE,SR ; Enter LPM0, enable interrupts
nop ; Required only for debugger
;
;-------------------------------------------------------------------------------
TA0_ISR; ISR for CCR0, Delay for Ref to settle
;-------------------------------------------------------------------------------
clr &TACTL ; clear Timer_A control registers
bic.w #LPM0,0(SP) ; Exit LPMx, interrupts enabled
reti ;
;-------------------------------------------------------------------------------
ADC12_ISR;
;-------------------------------------------------------------------------------
cmp.w R4,&ADC12MEM0 ; ADC12MEM0 = A10 > R4
jlo ADC_ISR_1 ; Again
bis.b #BIT0,&P1OUT ; P1.0 = 1
reti ;
ADC_ISR_1 bic.b #BIT0,&P1OUT ; P1.0 = 0
reti ;
;-------------------------------------------------------------------------------
COMMON INTVEC ; Interrupt Vectors
;-------------------------------------------------------------------------------
ORG TIMERA0_VECTOR ; Timer_A0 Vector
DW TA0_ISR
ORG ADC12_VECTOR ; ADC12 Vector
DW ADC12_ISR
ORG RESET_VECTOR ; POR, ext. Reset
DW RESET
END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -