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

📄 yinxiang.asm

📁 IPOD 音响 主要是将IPOD 音乐通过 功放放大
💻 ASM
📖 第 1 页 / 共 2 页
字号:
	voladdkey	bit	p1.7
	volmiuskey	bit	p1.2
	powerled	bit	p1.6
	bypass		bit	p1.2
	ledk		bit	p1.3
	amute		bit	p1.4
	sty		bit	p1.6
	ampmute		bit	p1.7
	SDA73		bit	p3.5
	SCL73		bit	p3.4
	;zhiled		bit	p1.6
;-------------------------------------------
	b21val		equ	21h
	bErr		bit	b21val.0
	status		equ	20h
	count		equ	30h
	losetimes	equ	31h
	i2cbit		equ	32h
	i2cdata		equ	33h
	module		equ	34h
	i2ctime		equ	35h
	i2csenddata	equ	36h
	volcount	equ	37h
	trblecount	equ	38h
	basscount	equ	39h
	datatemp	equ	3ah
;**********************************************************
        ORG	00h
 	aJMP	resert
	org	03h
;	ljmp	int_0
	org	50h
resert:
       	MOV	SP, #050H		; sp set cfh
     ;  	call	clrram
        call	iniuart
        setb	voladdkey
        setb	volmiuskey
        setb	scl73
        call	dly
        setb	sda73
	SETB	IT0 ;		设定INT0的触发方式为脉冲负边沿触发
	SETB	EX0 ;		打开INT0中断请求
	mov	p2,#11100111b
;	SETB EA 	;		打开CPU总中断请求
	mov	volcount,#18
	mov	i2csenddata,#11010111B
	mov	module,#03h
	call	sendata
;--------------------------------------------------------------------------
main:
;	SETB	IT0 ;		设定INT0的触发方式为脉冲负边沿触发
;	SETB	EX0 ;		打开INT0中断请求
;	mov	p2,#11100111b
	CLR	EA ;		打开CPU总中断
        JNB     P3.2, int_0
	jnb	voladdkey,tovolad
	jnb	volmiuskey,tovolmius
	jmp	main
;======================================
tovolad:
	call	delay
	jnb	voladdkey,tovolad_1
	jmp	main
tovolad_1:
	call	delay
	jnb	voladdkey,tovolad_2
	jmp	main
tovolad_2:
	jmp	keyvoladd
;----------------------------
tovolmius:
	call	delay
	jnb	volmiuskey,tovolmius_1
	jmp	main
tovolmius_1:
	call	delay
	jnb	volmiuskey,tovolmius_2
	jmp	main
tovolmius_2:
	jmp	keyvolmius
;============================================ remote  programm
exit:
;	SETB EA ;		允许中断
;	pop	psw
;	clr	rs1
;	clr	rs0
;	RETI ;
        JMP  MAIN
int_0:
;	push	psw
;	CLR EA ;	暂时关闭CPU的所有中断请求
	;clr	rs1
	;setb	rs0
	MOV R6,#10
SB:
	CALL YS1;		调用882微秒延时子程序
	JB P3.2,EXIT;		延时882微秒后判断P3.2脚是否出现高电平如果有就退出解码程序
	DJNZ R6, SB;		重复10次,目的是检测在8820微秒内如果出现高电平就退出解码程序
				;以上完成对遥控信号的9000微秒的初始低电平信号的识别。
	JNB P3.2, $ ;		等待高电平避开9毫秒低电平引导脉冲
	MOV	R6,#4
WAIT4MS:
	CALL YS1 ;		WAIT 4MS
	JNB	P3.2,EXIT
	DJNZ	R6,WAIT4MS
	JB	P3.2,$

	;MOV R7,#16;		忽略前16位系统识别码

	;JJJJA:JNB P3.2,$;	等待地址码第一位的高电平信号
	;LCALL YS1;		高电平开始后用882微秒的时间尺去判断信号此时的高低电平状态
	;MOV C,P3.2;		将P3.2引脚此时的电平状态0或1存入C中
	;JNC UUUA;		如果为0就跳转到UUUA
	;LCALL YS3;		检测到高电平1的话延时1毫秒等待脉冲高电平结束
	;UUUA: DJNZ R7,JJJJA
	MOV R1,#23H ;		设定1AH为起始RAM区
	MOV R2,#4;		接收从1AH到1BH的2个内存,用于存放操作码和操作反码
PP:
	 MOV R3,#8;		每组数据为8位

JJJJ:
	JNB P3.2,$;	等待地址码第一位的高电平信号
	LCALL YS1;		高电平开始后用882微秒的时间尺去判断信号此时的高低电平状态
	jnb    P3.2,JJJJ_1;		将P3.2引脚此时的电平状态0或1存入C中
	setb	c
	jmp	JJJJ_2
JJJJ_1:
	clr	c
JJJJ_2:
	JNC UUU;		如果为0就跳转到UUU
	LCALL YS3;		检测到高电平1的话延时1毫秒等待脉冲高电平结束
UUU:
	 MOV A,@R1;		将R1中地址的给A
	RRC A;			将C中的值0或1移入A中的最低位
	MOV @R1,A;		将A中的数暂时存放在R1数值的内存中
	DJNZ R3,JJJJ;		接收满8位换一个内存
	INC R1;			对R1中的值加1,换下一个RAM
	DJNZ R2,PP ;		接收完8位数据码和8位数据反码,存放在1AH/1BH中
;	mov	a,23h
;	cjne	a,#80h,exit
;	mov	a,24h
;	cjne	a,#7fh,exit
	MOV A,25H
	CPL A;			对1AH取反后和1BH比较
	CJNE A,26H,EXIT;	如果不等表示接收数据发生错误,放弃
;========================================操作程序
send:
	mov	a,25h
	cjne	a,#12h,send_1
	jmp	powerlab
send_1:
;	cjne	a,#1ah,send_2
;	jmp	ledlab
send_2:
	cjne	a,#1eh,send_3
	jmp	mutelab
send_3:
	cjne	a,#01h,send_4
	jmp	bypbasslab
send_4:
	cjne	a,#02h,send_5
	jmp	uparrow
send_5:
	cjne	a,#03h,send_6
	jmp	menu
send_6:
	cjne	a,#04h,send_7
	jmp	PRETRACK
send_7:
;	cjne	a,#05h,send_8
;	jmp	select
send_8:
	cjne	a,#06h,send_9
	jmp	NEXTTRACK
send_9:
	cjne	a,#07h,send_10
	jmp	PLAYPAUSE
send_10:
	cjne	a,#08h,send_11
	jmp	downarrow
send_11:
	cjne	a,#09h,send_12
	jmp	shuffle
send_12:
	cjne	a,#0ah,send_13
	jmp	trebleadd
send_13:
	cjne	a,#0ch,send_15
	jmp	treblemius
send_15:
	cjne	a,#1bh,send_16
	jmp	bassadd
send_16:
	cjne	a,#0dh,send_17
	jmp	bassmius
send_17:
	cjne	a,#1fh,send_18
    ;     cjne	a,#1Ah,send_18
	jmp	voladd
send_18:
	cjne	a,#0eh,send_19
   ;     cjne	a,#05h,send_19
	jmp	volmius
send_19:
	jmp	exit
;***************************************************remote lose key programm
losekey:
	setb	status.1
	mov	r7,#37
losekey_1:
	call	D39MS
	jnb	p3.2,losekey_2
	djnz	r7,losekey_1
losekey_1_1:		;lose key
	clr	status.1
	jmp	loseexit
losekey_2:
	mov	losetimes,#6
losekey_2_1:
	call	YS1
	jb	p3.2,lowloseexit; if low 9ms, is high to exit
	djnz	 losetimes,losekey_2_1
	jnb	p3.2,$	; wait low 9ms
;----------------------------------- repeat high 2ms
	;mov	losetimes,#2
losekey3:
	;call	YS1
	;jnb	p3.2,loseexit
	;djnz	losetimes,losekey3
	;clr	status.1	; lose key

loseexit:
	ret
lowloseexit:
       clr  status.1
	ret
;================================================  remote delay
YS1: MOV R4,#18 ;	延时子程序1,精确延时882微秒
D1: MOV R5,#21
DJNZ R5,$
DJNZ R4,D1
RET
;------------------------------------
YS2:
	 MOV R4,#10 ;	延时子程序2,精确延时4740微秒
D2:
	MOV R5,#217
	DJNZ R5,$
	DJNZ R4,D2
RET
;-------------------------------------------
YS3:
	MOV R4,#2;		延时程序3,精确延时1000微秒
D3:
	MOV R5,#228
DJNZ R5,$
DJNZ R4,D3
RET
;--------------------------------------
D39MS:
	MOV R4,#6;		延时程序3,精确延时3000微秒
D39:
	MOV R5,#228
        DJNZ R5,$
DJNZ R4,D39
RET
;*******************************************************remote lose key programm end
;*************************************************************** remote status
keyvoladd:
	mov	module,#03
	mov	dptr,#VOLTAB
	mov	a,volcount
	cjne	a,#0,keyvoladd_1
	jmp	keyvoladd_2
keyvoladd_1:
	dec	volcount
keyvoladd_2:
	mov	a,volcount
	movc	a,@a+dptr
	anl    a,#7fh
	mov	i2csenddata ,a
	mov	i2ctime,#8
	call	sendata
	call	delay80ms
	jnb	voladdkey,keyvoladd
	jmp	main
;=========================================
keyvolmius:
	mov	module,#03h
	mov	dptr,#VOLTAB
	mov	a,volcount
	cjne	a,#80,keyvolmius_1
	jmp	keyvolmius_2
keyvolmius_1:
	inc	volcount
keyvolmius_2:
	mov	a,volcount
	movc	a,@a+dptr
        anl    a,#7fh
	mov	i2csenddata,a
	mov	i2ctime,#8
	call	sendata
	call	delay80ms
	jnb	volmiuskey,keyvolmius
	jmp	main
;=========================================
powerlab:
	cpl	powerled
	mov	dptr,#powerontab
	call	simplesend
	jmp	exit
;==========================================
ledlab:
	cpl	ledk
ledlab_1:
	call	losekey
	jb	status.1,ledlab_1; no losekey go on
	jmp	exit
;========================================
mutelab:
	cpl	sty
	cpl	ampmute
	mov	dptr,#menutab
	call	simplesend
	jmp	exit
;========================================
bypbasslab:
	cpl	bypass
bypbasslab_1:
	call	losekey
	jb	status.1,bypbasslab_1; no losekey go on
	jmp	exit

;==========================================
shuffle:
	mov	dptr,#shffletab
	call	simplesend
	jmp	exit
;=========================================
trebleadd:
	mov	module,#0ch
	mov	dptr,#TONEtab
	mov	a,trblecount
	cjne	a,#0,trebleadd_1
	jmp	trebleadd_2
trebleadd_1:
	dec	trblecount
	mov	a,trblecount
	movc	a,@a+dptr
	swap	a
	mov	datatemp,a
	mov	a,basscount
	movc	a,@a+dptr
	anl	a,#0fh
	orl	a,datatemp
	mov	i2csenddata,a
	call	sendata
trebleadd_2:
	call	losekey
	jb	status.1,trebleadd_2; no losekey go on
	jmp	exit
;========================================
treblemius:
	mov	module,#0ch
	mov	dptr,#TONEtab
	mov	a,trblecount
	cjne	a,#13,treblemius_1
	jmp	treblemius_2
treblemius_1:
	inc	trblecount
	mov	a,trblecount
	movc	a,@a+dptr
	swap	a
	mov	datatemp,a

⌨️ 快捷键说明

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