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

📄 lab3.asm

📁 pic单片机资料
💻 ASM
字号:
		#INCLUDE p16F877A.inc	; Include the standard definitions

Start
		BANKSEL	TRISC		; BANKSEL to get to TRISC bank (bank 1)
		bcf		TRISC,2		; Set CCP1 as an output
		movlw	D'70'		; Manualy Calculated Period
		movwf	PR2			;  loaded into PR2 (also in bank1)
		BANKSEL	CCPR1L		; BANKSEL is needed to get bank to bank 0.
		movlw	D'35'		; Manually Calculated Duty Cycle (50%)		
		movwf	CCPR1L		;  loaded into CCPR1L
		movlw	0x06		; Turn on TMR2 (for PWM) 
		movwf	T2CON		; and /16 prescale

CheckButton
		btfsc	PORTA,4		; Test the button - if pressed, its a low signal. 
		goto	ButtonOff	; if high (not pressed), go to "Button Off" code

ButtonOn
		movlw	H'0C'		; if low (pressed), fall here to "Button On" code.
		movwf	CCP1CON		; this turns on CCP1CON by writing 0C (hex) to it.
		goto	CheckButton	; go check the button again (back to CheckButton)

ButtonOff
		clrf	CCP1CON		; Turn off CCP1 module by writing 0 to it
		goto	CheckButton	; go check the button again (back to CheckButton)
		END					; All programs must have an END directive
		

⌨️ 快捷键说明

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