Em78p458/9 比较器功能测试程序
扫描二维码
随时随地手机看文章
;***********************************************************************;
;title: Em78p458/9 comparator test program ;
;Description:比较器结果由Port60输出,当R3的bit7为1时,输出high pulse,当R3的 ;
; bit7为0时,输出low pulse.比较器输出由port57输出与port60一样的 ;
; 波形。 ;
;Company: ELAN MICROELECTRONICS (SZ) LTD.INC ;
;************************************************************************;
include "d:wiceincem78_headfileem78p458.inc" ;include em78p458 head file
;=================================================================================
dly1 == 0x30 ;delay register 1
dly2 == 0x31 ;delay register 2
;----------------------------------------------------------
org 0
jmp start
org 0x08
reti
start:
disi
mov a,@0b00000000
contw ;set cont register
bs r9,5 ; register segment
mov a,@0b00000000
iow ioc51 ;set port51,52 funtion
bc r9,5 ;
mov a,@0b01100000 ;bit6(CE)=1,enable comparator,
;bit5(coe)=1,set comparator
iow ioca0
mov a,@0b01100000
iow ioc50 ;set port56,57 input,
mov a,@0b00000000
iow ioc60 ;set port6 output
start1:
mov a,@0b00010100
mov port5,a ;CIN+
nop
call compout ;port60 output low
mov a,@0x32
call delay ;delay time 5ms
;
mov a,@0b00010010
mov port5,a ;CIN+>CIN-
nop
nop
call compout ;port60 output high
mov a,@0x64
call delay ;delay time 10ms
;
mov a,@0b00001100
mov port5,a ;CIN+
nop
call compout ;Port60 output low
mov a,@0x96
call delay ;delay time 15ms
;
mov a,@0b00001010
mov port5,a
nop
nop
call compout ;port60 output high
mov a,@0xC8
call delay ;delay time 20ms
jmp start1
;--------------------------
compout: ;port60 output subprogram
jbs status,7
jmp comparator0
comparator1:
bs port6,0
jmp $+2
comparator0:
bc port6,0
ret
;---------------------
delay: ;delay time subprogram
mov dly1,a
delay1:
mov a,@0x15 ;100us delay time,4MHz,cLOCk=4
mov dly2,a
delay2:
djz dly2
jmp delay2
djz dly1
jmp delay1
ret
;-----------------
eop
end