⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decoder.asm

📁 HT6221發碼的接收 汇编
💻 ASM
字号:
include	ht48r30a-1.inc
; ***********************************************
; * Filename : DECODER.asm                      *
; * Function : DECODER HT6221_2		        *
; * Microprocessor : HT48R30A-1                 *
; * Crystal : 4MHz                              *
; ***********************************************
data	.section	'data'
card_no0		equ	[060h]		; the buffer of store the IR number
card_no1           	equ     [061h]
card_no2          	equ     [062h]
card_no3           	equ     [063h]
temp			equ	[07eh]
cint		db	?
count		db	?
count_buf	db	?
int_acc		db	?
right_tou	dbit
y_bit	dbit
;-----------------------------------------
code	.section	at 0000 'code'
	org 	00h

	jmp	start
	org	04h			
	jmp	do_wait
	org	08h
	jmp	do_tmr			

	org	20h	
start:
	set	pgc			;setting the int port as input port
	call	init
	mov	a, 81h			;fsys/4 1M
	mov	tmrc, a
	mov	a, 56
	mov	tmr, a			;every 200us the interrupt will occur
	mov	a, 6
	mov	intc, a
	set	tmrc.4
;------------------------------------------------------
sleep:
	set	intc.0
	snz	y_bit			;judge the interrupt had occured?
	jmp	sleep			;hold on  wating
	call	decode_1		;decode
	snz	right_tou		
	jmp	start           	;the number is wrong,try again
	mov	a, cint			
	sub	a, 32			;there are 32 bits in all
	snz	c			;the number is over?
	jmp	sleep           	
                                	
	clr	tmrc			;receiver over
	clr	intc
	cpla	card_no2
	xor	a, card_no3		;check the number
	snz	z
	jmp	error1
	jmp	start			;code right
error1:
	jmp	start			;code wrong
;---------------------------------
do_wait :
	clr	tmrc.4
	clr	intc.0
	mov	int_acc, a		;interrupt protect, push acc
	mov	a, count
	mov	count_buf, a
	clr	count
	set	y_bit
over_int:
	mov	a, 56
	mov	tmr, a
	mov	a, int_acc		;pop acc
	set	tmrc.4
	set	intc.0
	reti
;----------------------
do_tmr:
	inc	count
	reti
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
decode_1 proc
	clr	intc.0
	clr	y_bit
	snz	right_tou
	jmp	judge_touma
	mov	a, count_buf
	sub	a, 4
	snz	c
	jmp	error			;if data<200us*4=0.8ms,then
	mov	a, count_buf
	sub	a, 13
	sz	c
	jmp	error			;if data>200us*13=2.6ms,then error error
	mov	a, count_buf		;if data>200us*8=1.6ms,then c=1,data=1
	sub	a, 8			;if data<200us*8=1.6ms,then c=0,data=0
	rrc	card_no3
	rrc	card_no2
	rrc	card_no1
	rrc	card_no0
	inc	cint			
	ret
error:
	clr	count
	clr	right_tou
	ret	
judge_touma:
	clr	right_tou			;the head code's length 13.50ms 
	mov	a, count_buf
	sub	a, 70			;200*70=14ms
	sz	c			;
	ret				;headcode >14ms ,error
	mov	a, count_buf
	sub	a, 63			;63*200=12.6ms
	snz	c
	ret				;headcode <12.6ms ,error
	set	right_tou
	ret
decode_1 endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;Function :	init
;Purpose  :	clear ram value
;Parameter:	
;Return   :
;Modified :	acc, status
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
init proc
	clr	intc		
	mov	a, 20h
	mov	mp0, a
	mov	a, 5fh
	mov	temp, a
ram_clr:			
	clr	r0
	inc	mp0
	sdz	temp
	jmp	ram_clr
	ret
init endp


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -