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

📄 ir.txt

📁 EM78P468单片机汇编详细代码
💻 TXT
字号:
;================================================
;=========== 468红外发送宏定义 ==================
;================================================
send_ir_code macro id,scl,lpw0,hpw0,lpw1,hpw1,num,addr,bank_sel	

	if 		id==0
	
	disi	
	mov		a,clock_control
	mov		addr+3,a
	bs		clock_control,0		;cpus=1
	bs		clock_control,4		;main clock=2.13M
	bc		clock_control,5
	bc		clock_control,6		
	bank	bank_sel			;select ir bank	
	bc		port5,0				;control register page0	
	ior		ioc50
	and		a,@0x7f	
	iow		ioc50				;port5.7 as output	
	bs		re,iroute		;set p5.7 as ir output	
	bs		port5,7			;set irout=1	
	bs		port5,0			;control register page1	
	ior		ioc61
	or		a,@0x80
	iow		ioc61			;irout => 24ma		
	ior		ioc91
	and		a,@0x0f
	or		a,@0b10000000
	iow		ioc91			;counter2 scale	
	bc		port5,0			;control register page0
	mov		a,@0x0d	
	iow		iocc0			;counter2 preset value		
	ior		iocf0
	or		a,@0x60		
	iow		iocf0			;enable lpwte\hpwte int	
	
	elseif	id==1
	
	bs		port5,0	
  
	mov		a,@scl			;1:64
	iow		ioca1			;lpwt\hpwt scale
	bc		port5,0		
	mov		a,@lpw0			;low pulse width
	iow		ioce0	
	nop			
	mov		a,@hpw0			;high pulse width
	iow		iocd0	
	bs		re,hf			;hf=1
	bs		re,ire			;ire=1		
	mov		a,@0b00001110	
	or		rc,a			;enable lpw\hpw\counter2	
	bc		rf,5
	bc		rf,6	
	jbs		rf,6			;send low
	jmp		$-1				;wait to test	
	bc		rf,6	
	bc		re,ire			;disable ir
	bs		port5,7			;set irout=1		
	jbs		rf,5			;send high
	jmp		$-1				;wait to test	
	bc		rf,5		
	mov		a,rc
	and		a,@0xf1
	mov		rc,a			;disable lpw\hpw\counter2	
	bc		re,hf			;hf=0
	bc		re,ire			;ire=0	
	
	elseif	id==2	
	bank	bank_sel		;select ir bank
	bs		port5,0
	mov		a,@scl	
	iow		ioca1			;lpwt\hpwt scale: 1/32		
	bc		port5,0			;control register page0	
	mov		a,@num			;codes number
	mov		addr+0,a	
	mov		a,@addr+4		;first address
	mov		r4,a
	bank	bank_sel		;select ir bank
$read_one_byte:	
 
 	    mov		a,@0x08
	mov		addr+2,a		;1byte flag	
    mov		a,r0  	   	   	
	mov		addr+1,a		;first code			
$send_one_bit:		
	bc		status,cy
	rrc		addr+1			;next bit	
	mov		a,@lpw0
	jbc    	status,cy
	mov		a,@lpw1	
	iow		ioce0			;low pulse width
	mov		a,@hpw0
	jbc    	status,cy
	mov		a,@hpw1	
	iow		iocd0			;high pulse width	
	
	bs		re,hf			;hf=1
	bs		re,ire			;ire=1		
	mov		a,@0b00001110	
	or		rc,a			;enable lpw\hpw\counter2	
	bc		rf,5
	bc		rf,6	
	jbs		rf,6			;send low
	jmp		$-1				;wait to test	
	bc		rf,6	
	bc		re,ire			;disable ir
	bs		port5,7			;set irout=1		
	jbs		rf,5			;send high
	jmp		$-1				;wait to test	
	bc		rf,5		
	mov		a,rc
	and		a,@0xf1
	mov		rc,a			;disable lpw\hpw\counter2	
	bc		re,hf			;hf=0
	bc		re,ire			;ire=0		
	djz		addr+0			;all bits end?
	jmp		$send_next_bit	
	jmp		$send_data_ret
$send_next_bit:
	djz		addr+2			;1byte finish?
  
	jmp		$send_one_bit
	inc		r4				;next address	
	jmp		$read_one_byte	
$send_data_ret:
	nop
	
	elseif	id==3
	ior		iocf0
	and		a,@0x9f		
	iow		iocf0			;disable lpwte\hpwte int	
	mov		a,addr+3
	mov		clock_control,a
	else
	message "waring:num of bank is not exist"
	endif	
	endm

⌨️ 快捷键说明

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