📄 实验8_adc12_a0-ref=1.5v.s43
字号:
#include "msp430x44x.h" // Standard Equations
;******************************************************************************
; MSP-FET430P440 Demo - ADC12, Using the Internal Reference
;
; Description: This program will show how to use the internal reference
; for ADC12.
;
; This example shows how to use the internal reference of the ADC12.
; It uses the internal 1.5V reference and performs a single conversion
; on channel A0. The conversion results are stored in ADC12MEM0 and are
; moved to R5 after the conversion is complete.
; Each conversion result is stored in ADC12MEM0 and is moved to a RAM
; location. The conversion results are moved to RAM addresses 0x200 - 0x4FF.
; Test by applying a voltage to channel A0, then running. To view the
; conversion results, open a memory window in C-Spy and view the contents of
; addresses 0x200 - 0x4FF after stopping program execution.
; Remember the conversion results are 12-bits so you must set the memory window
; to 16-bit mode. Test by applying a voltage to channel A0, then setting and
; running to a break point at "clr R5". To view the conversion results, open a
; memory window in C-Spy and view the contents of 0x200-0x4FF.
;
;
; MSP430F449
; ---------------
; | |
; | A0 (P6.0)|<---- Vin
; | |
;
;------------------------------------------------------------------------------
Results EQU 0200h ; Begining of Results table
;------------------------------------------------------------------------------
main ORG 01100h ; Program Start
;------------------------------------------------------------------------------
RESET mov #0A00h,SP ; Initialize stackpointer
StopWDT mov #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog
bis.b #BIT0,&P6SEL ; Enable A/D channel A0
;
SetupADC12 mov #SHT0_8+MSC+REFON+ADC12ON,&ADC12CTL0
; Turn on ADC12, use int. osc.
; Extend sampling period to avoid
; overflow
; Set MSC so conversions triggered
; automatically
; turn on 1.5V ref
mov #SHP+CONSEQ_2,&ADC12CTL1
; Use sampling timer,set mode
mov.b #SREF_1,&ADC12MCTL0 ; Vr+=Vref+
mov #BIT0,&ADC12IE ; Enable ADC12IFG.0 for ADC12MEM0
mov #03600h,R15 ; Delay for needed ref start-up.
L$1 dec R15 ; See datasheet for details.
jnz L$1
eint ; Enable interrupts
clr R5 ; Clear results table pointer
Mainloop bis #ENC,&ADC12CTL0 ; Enable conversions
bis #ADC12SC,&ADC12CTL0 ; Start conversions
bis #CPUOFF,SR ; Hold in LPM0
nop ; Need only for C-SPY
;
;------------------------------------------------------------------------------
ADC12ISR ; Interrupt Service Routine for ADC12
;------------------------------------------------------------------------------
mov &ADC12MEM0,Results(R5); Move result, IFG is reset
incd R5 ; Increment results table pointer
; and #0ffh,R5 ; Modulo pointer
cmp #0300h,R5
jnz adret
clr R5
nop
adret reti ;
;
;------------------------------------------------------------------------------
; Interrupt Vectors
;------------------------------------------------------------------------------
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET ;
ORG 0FFEEh ; ADC12 Interrupt Vector
DW ADC12ISR ;
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -