?? initialize.asm
字號:
;**********************************************
;Name :RAMInitial
;Function:clr bank0~bank1
;Input :
;Output :
;Register Used:
;***********************************************
RAMInitial:
clr y
mov a,#7fh
b0mov z,a
Clrbank0:
clr @YZ ;Clear @YZ content
decms Z ;z = z - 1 , skip next if z=0
jmp Clrbank0
clr @YZ ;Clear address 0x00
;-----
;preset some constant
mov_ timer10ms,#20 ;10ms
mov_ timer200ms,#20 ;200ms
mov_ timer1s,#100 ;1s
mov_ timer1m,#60 ;1m
mov_ timer1h,#60 ;1h
mov_ displaytimer,#2
mov_ combuf,#11111111b ;set all com high level
mov a,#50 ;set led frequent=0.5s
mov ledfrequent,a
mov loadfrequent,a
ret
;**********************************************
;Name :PortInitial
;Function:
;Input :
;Output :
;Register Used:
;***********************************************
PortInitial:
mov a,#0ffh
mov p2m,a ;set p2 is output port
mov p2,a ;set all p2 pin high level
mov a,#11110000b ;set p4.7~p4.4 is output,others is input
mov p4m,a
mov a,#11110000b
mov p4,a
clr p4ur
mov a,#11111111b
mov p5m,a ;set p5 is output except p5.1
mov a,#11001011b
mov p5,a
ret
;**********************************************
;Name :SysInitial
;Function:
;Input :
;Output :
;Register Used:
;***********************************************
SysInitial:
;-----
clr t0m ;ftc1=fcpu
bclr ftc0ien ;dis t0 int
bclr ftc0enb ;stop t0 count
mov A,#01100100B ;//f0=fcpu/4
;// mov A,#01010100B ;//f0=fcpu/4
b0mov Tc0M,A
mov A,#131 ;//0.5ms constant for f0=1mips/64
;// mov A,#194 ;0.25ms
b0mov Tc0C,A
b0mov Tc0r,a
b0bset FTc0ENB ; Enable TIMER0
bset FTc0IEN ; Enable T0 interrupt
bclr ftc0irq ; CLEAR TIMER0 INTERRUPT FLAG
;----
;初始化pwm
bclr ftc1ien ;dis t1 int
clr tc1c
;// mov a,#01100100b
mov a,#01100010b
b0mov tc1m,a ;set pwm=32 duty fpwm=62.5k
bclr ftc1out
bclr fpwm1out
bclr ftc1enb ;stop t1 count
bclr ptpwm
;----
clr ADM
b0bset FADENB ;enable adc
mov_ ADR,#01010000b ;select 12 bit ADC,Fcpu/2=128us
;----
bclr fp00irq
mov_ pedge,#10h ;p00 falling edge
bset fp00ien
bclr fp01irq ;p01 falling edge
;// bset fp01ien
;----
bset poweronflag ;通電標志
b0bset FGIE ;//enable Interrupt gain
ret
;**********************************************
;Name :Pdelay
;Function:
;Input :
;Output :
;Register Used:
;***********************************************
Pdelay:
mov a,#0ffh
mov var1,a
loop10:
mov a,#0ffh
mov var2,a
loop11:
decms var2
jmp loop11 ;power on delay
decms var1
jmp loop10
ret
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -