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

📄 ex0601.asm

📁 关于PIC16F877A单片机的一些源代码,比较丰富.初学者认真看看应该有收获的.
💻 ASM
字号:
;
;	EX0601.ASM
;
	LIST P=16F877, R=DEC
	#INCLUDE P16F877.INC
	CBLOCK 0X20
	ENDC
;
;	define RAMs
;
	ORG 0
	NOP
	BANKSEL TRISB
	MOVLW 0
	MOVWF TRISB
	MOVWF PORTD
	BANKSEL PORTB
	MOVLW H'FF'	; TURN OFF LEDS
	MOVWF PORTB
;
	CLRF DATBF1	; CLEAR DATA BUFFERS
	CLRF DATBF2
;
;=======================
MAIN:
	BANKSEL ADCON1		; ADCON1 is in bank1
	MOVLW B'10001110'	; select right(1) justified (d7)
				; 1 ch(AN0)/0 refs
	MOVWF ADCON1
;
	BANKSEL ADCON0
	MOVLW B'01000001'	; select Fosc/8(01), AN0(000)
	MOVWF ADCON0		; a/d done(0), x(0), a/d ON(1)
;
	CALL DLY2_5mS		; wait for input charge
MAIN1:
	BSF ADCON0,GO		; start a/d converting
MAIN2:
	BTFSC ADCON0,GO		; a/d convertion finished?
	GOTO MAIN2		; no	
;
	BANKSEL ADRESL		; select bank1
	MOVF ADRESL,W		; read a/d result ( low byte )
;
	BANKSEL DATBF1		; select bank0
	MOVWF DATBF1		; store (0~7) in DATBF1
	MOVF ADRESH,W		; read a/d result ( high byte )
	MOVWF DATBF2		; store (8~9) in DATBF2
;
	CALL FOURLED		; display a/d results
	GOTO MAIN1
;
;---------------------------------------------------------------;
								;
	#INCLUDE <FOURLED.INC>					;
								;
;	externally defined pins (in main program)		;
								;
PORTSEG EQU PORTD	; segment port				;
TRISEG  EQU TRISD	; direction of segment port		;
PORTCA  EQU PORTB	; common anode port			;
TRICA   EQU TRISB	; direction of segment port		;
								;
	#INCLUDE <DLY2_5mS.INC>					;	
								;
;===============================================================;
;
;
;
	END

⌨️ 快捷键说明

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