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

📄 init2.asm

📁 用PIC16F690单片机实现终端采样、检测和与PC通讯
💻 ASM
字号:
	list p=16f690
	#include p16f690.inc
	#include<t2.inc>

	CODE

;init---------------------------------------------------------------------------
init
	;clock frequency =8MHz
	BANKSEL	0x80
	movlw			0xF1
	movwf			OSCCON

	;time 100ms*10=1s
	;timer1
	BANKSEL	0x00
	movlw			t1low
	movwf			TMR1L
	movlw			t1hi
	movwf			TMR1H
	movlw			0x30	;timer frequency =1:8 Fosc =1MHz
	movwf			T1CON

	BANKSEL	0x80
	clrf				PIE1
	bsf				PIE1,TMR1IE

	BANKSEL	0x00
	clrf				INTCON
	bsf				INTCON,PEIE
	bsf				INTCON,GIE

	movlw			0x0A
	movwf			t_count

	;serial interface
	BANKSEL	0x80
	clrf				BAUDCTL
	movlw			0x18
	movwf			TXSTA

	BANKSEL	0x00
	movlw			0x80
	movwf			RCSTA

	movlw			0xCF
	movwf			SPBRG
	clrf				SPBRGH

	;ADC
	BANKSEL	0x80
	movlw			0x07
	movwf			TRISA
	movlw			0xCF
	movwf			TRISC

	BANKSEL	0x00
	clrf				PORTA
	clrf				PORTB
	clrf				PORTC

	BANKSEL	0x80
	movlw			0x50
	movwf			ADCON1

	;others
	bcf				TRISB,6
	BANKSEL	0x00
	bcf				PORTB,6

	clrf				ad_count
	clrf				t_flag

	return
;init end----------------------------------------------------------------------
	END

⌨️ 快捷键说明

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