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

📄 transmit.asm

📁 this prog must be used with the pic_receive.rar file . I wish the two programs will hope some mcu p
💻 ASM
字号:
   
;~~~~~~~~~~~~~~~~~~~~~~~~~ ------ ~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;		   
;			   Hardware Settings
;
;	I/O   Active	Functional Description		    
;
;	GP0	1	On/Off signal LED		
;	GP1	1	Cycle signal LED		
;	GP2	1	signal out				
;	GP3	1	Key					
;	GP5	1	transmit signal LED					
;

 processor 12CE519
 include <P12ce519.inc>

;********************* USER DEFINED Register definitions ******************

TIMES		equ	0x7	;apply to count
TIMESd		equ	0x8
countd		equ	0x9	;apply to count
TIMESa		equ	0xa
counta		equ	0xb	;apply to count
count		equ	0xc	;apply to count
KPT		equ	0xd	;key pressed times
		
sendCODE	equ	0xe	
sendBIT		equ	0xf
INITcode	equ	0x10
DEVNOcode	equ	0x11
INSTcode	equ	0x12
ENDcode		equ	0x13

FAN		equ	0x14
GPIO_STK	equ	0x15



; end USER DEFINED Register definitions

;**************************************************************************

; program start and interupt definition

	org	0x00

power_on_and_reset
	nop
	nop
	nop
	nop
	nop

	call	InitPorts
	goto	Main		;if weak up from sleep

;**************************************************************************

;This routine will define all initial value of PORTS.

;**************************************************************************

InitPorts
	movlw	B'001000'	;Port direction
	TRIS	GPIO
	movlw	B'000000'	;Port initial value
	movwf	GPIO		
	movlw	B'11000000'	;init. OPTION reg.
	OPTION		
	return	

;**************************************************************************

Main
	btfsc	GPIO,3		;key pressed?
	goto	Main		;if no

	movlw	D'255'
	movwf	TIMESa		;set 1 Sec
	clrf	counta
	clrf	KPT

ckkey	btfsc	GPIO,3		;key released?
	goto	Main2		;if yes
	
	decfsz	counta,1
	goto	ckkey
	decfsz	TIMESa,1	;over 1 Sec?
	goto	ckkey		;if no
	goto	INSTnf		;if yes,set On/Off

Main2	incf	KPT,1		;key pressed times +1
	movlw	D'255'
	movwf	TIMESa		;set 1 Sec
	clrf	counta
ckkey2	btfss	GPIO,3		;key pressed?
	goto	ckkey		;if yes
		
	decfsz	counta,1
	goto	ckkey2
	decfsz	TIMESa,1	;over 1 Sec?
	goto	ckkey2		;if no
	goto	INSTrc		;if yes,set cycle signal

INSTrc	
	movlw	D'5'
	subwf	KPT,0
	btfsc	STATUS,C
	goto	ckkeylp
	movf	KPT,0		;set instruction code = cycle
	movwf	INSTcode
	bcf	GPIO,0
	bsf	GPIO,1
	goto	operation

INSTnf	
	movlw	D'5'
	subwf	KPT,0
	btfsc	STATUS,C
	goto	ckkeylp
	movlw	B'01000010'	;set instruction code = On/Off
	movwf	INSTcode
	bsf	GPIO,0
	bcf	GPIO,1
	goto	operation
	

;**************************************************************************
		
operation
	bsf	GPIO,5		;switch on transmit signal LED	
send	bsf	GPIO,2		;to touch off receiver
	bcf	GPIO,2
	call	delays
	nop
	nop
	nop
	nop
	nop

	nop
	nop
	nop
	nop
	nop

	nop
	nop
	nop
	nop
	nop

	nop
	nop
	nop			;18


	movlw	B'11000011'	;set initial code	
	movwf	sendCODE	;		 	
	movlw	D'8'		;initial code bit	
	movwf	sendBIT		;			
	call	transmit	;start transmitting	
	nop

	movlw	B'00001001'	;set device no code
	movwf	sendCODE
	movlw	D'8'		;device no code bit
	movwf	sendBIT
	call	transmit	;start transmitting
	nop

	movf	INSTcode,0	;set instruction code
	movwf	sendCODE
	movlw	D'8'		;instruction code bit
	movwf	sendBIT
	call	transmit	;start transmitting
	nop

	movlw	B'01100000'	;set end code
	movwf	sendCODE	
	movlw	D'8'		;end code bit
	movwf	sendBIT
	call	transmit	;start transmitting
	nop

	bcf	GPIO,5		;switch off transmit signal LED
ckkeylp	btfss	GPIO,3		;key released?
	goto	ckkeylp
	goto	Main

;**************************************************************************

transmit			;send code

	rlf	sendCODE,1	;move code to STATUS,C		
	call	delayf
	btfss	STATUS,C	;the code is "0"		
	goto	send0		;if yes,send "0" out		
	goto	send1		;else,send "1" out		
send0
	nop			;				
	bcf	GPIO,2		;transmitting "0" out		[31]	
	goto	ckbit		;				
send1
	bsf	GPIO,2		;transmitting "1" out		[31]
	goto	ckbit

ckbit	decfsz	sendBIT,1	;finished?			
	goto	transmit	;if no				
	return			;		

;**************************************************************************

Debounce			;apply to key
	movlw	D'1'
	movwf	TIMESd
	clrf	countd
	goto	delayloop

delayf				;apply to frequency of send signal
	movlw	D'1'
	movwf	TIMESd
	movlw	D'10'
	movwf	countd
	goto	delayloop

delays				;apply to delay send
	movlw	D'1'
	movwf	TIMESd
	movlw	D'80'
	movwf	countd
	goto	delayloop

delay03				;apply to 
	movlw	D'10'
	movwf	TIMESd
	clrf	countd
	goto	delayloop

delay04				;apply to 
	movlw	D'20'
	movwf	TIMESd
	clrf	countd
	goto	delayloop

delay255			;apply to reset	
	movlw	D'255'
	movwf	TIMESd
	clrf	countd
	goto	delayloop

delayloop
	decfsz	countd,1
	goto	delayloop	;no,check again
	decfsz	TIMESd,1	;TIMES-1=0?
	goto	delayloop	;no,loop again
	return

	end	




⌨️ 快捷键说明

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