;***********************************************************************;
;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:\wice\inc\em78_headfile\em78p458.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
上一篇:EMC8BIT单片机指令应用的误区与技巧
下一篇:S3F9454/9444下驱动蜂鸣器的编程示例
推荐阅读最新更新时间:2024-03-16 15:53