在线时间50 小时
UID263044
注册时间2011-2-16
NXP金币0
TA的每日心情 | 开心 2018-9-14 09:26 |
---|
签到天数: 2 天 连续签到: 1 天 [LV.1]初来乍到
高级会员

- 积分
- 952
- 最后登录
- 2021-1-4
|
;*******************************************************************
;* This stationery serves as the framework for a user application. *
;* For a more comprehensive program that demonstrates the more *
;* advanced functionality of this processor, please see the *
;* demonstration applications, located in the examples *
;* subdirectory of the "Freescale CodeWarrior for HC08" program *
;* directory. *
;*******************************************************************
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
;
; export symbols
;
XDEF _Startup
ABSENTRY _Startup
;
; variable/data section
;
ORG RAMStart ; Insert your data definition here
ExampleVar: DS.B 1
adChannelSel: ds.b 1
adValueChannel0H: ds.b 1
adValueChannel0L: ds.b 1
adValueChannel1H: ds.b 1
adValueChannel1L: ds.b 1
adValueChannel2H: ds.b 1
adValueChannel2L: ds.b 1
adValueChannel3H: ds.b 1
adValueChannel3L: ds.b 1
;
; code section
;
; ORG ROMStart
_Startup:
LDHX #RAMEnd+1 ; initialize the stack pointer
TXS
CLI ; enable interrupts
lda #$03 ;Disable Copt, Reset,BKBD enanble
sta SOPT1
jsr initialAdc
mainLoop:
; Insert your code here
jsr adcTask
jsr adcIsr
nop
nop
BRA mainLoop
;*******************************************************************
initialAdc:
;ADCSC2
lda #%00000000
sta ADCSC2
;ADCCFG
lda #%10001000
sta ADCCFG
;APCTL1
lda #$0f
sta APCTL1
lda #$00
sta APCTL2
;ADCSC1 setting
lda #%00000000
sta ADCSC1
lda #$00 ;start form ad channel0 t
sta adChannelSel
initialAdc_end:
rts
;*******************************************************************
adcTask:
lda adChannelSel
cmp #$00
bne adcTaskChannel1Setting
adcTaskChannel0Setting:
lda #$01
sta adChannelSel
jmp adcTaskEnd
adcTaskChannel1Setting:
cmp #$01
bne adcTaskChannel2Setting
lda #$02
sta adChannelSel
jmp adcTaskEnd
adcTaskChannel2Setting:
cmp #$02
bne adcTaskChannel3Setting
lda #$03
sta adChannelSel
jmp adcTaskEnd
adcTaskChannel3Setting:
lda #$00 ;start form ad channel0 t
sta adChannelSel
adcTaskEnd:
lda adChannelSel
ora #%00000000
sta ADCSC1
adcTaskEndAB:
; lda ADCSC1
; and #$80 ;test COCO
; cmp #$80
brclr 7,ADCSC1,adcTaskEndAB
rts
;*******************************************************************
adcIsr:
lda adChannelSel
cmp #$00
bne adcIsrStoreChannel1Value
adcIsrStoreChannel0Value:
lda ADCRH
sta adValueChannel0H
lda ADCRL
sta adValueChannel0L
jmp adcIsrEnd
adcIsrStoreChannel1Value:
cmp #$01
bne adcIsrStoreChannel2Value
lda ADCRH
sta adValueChannel1H
lda ADCRL
sta adValueChannel1L
jmp adcIsrEnd
adcIsrStoreChannel2Value:
cmp #$02
bne adcIsrStoreChannel3Value
lda ADCRH
sta adValueChannel2H
lda ADCRL
sta adValueChannel2L
jmp adcIsrEnd
adcIsrStoreChannel3Value:
cmp #$03
bne adcIsrEnd
lda ADCRH
sta adValueChannel3H
lda ADCRL
sta adValueChannel3L
jmp adcIsrEnd
adcIsrEnd:
rts
;**************************************************************
;* spurious - Spurious Interrupt Service Routine. *
;* (unwanted interrupt) *
;**************************************************************
;spurious: ; placed here so that security value
; NOP ; does not change all the time.
; RTI
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
; org $ffd0
; dc.w adcIsr
;
; ORG $FFFA
; DC.W spurious ;
; DC.W spurious ; SWI
; DC.W _Startup ; Reset
////////////////////////////////////////////////////////////////////////////////////////
其中有几行
adcTaskEnd:
lda adChannelSel
ora #%00000000
sta ADCSC1
adcTaskEndAB:
; lda ADCSC1 ---------这行读值,本来是0X81,可是只能读出0x01
; and #$80 ;test COCO
; cmp #$80
brclr 7,ADCSC1,adcTaskEndAB
|
|