init2.asm
来自「用PIC16F690单片机实现终端采样、检测和与PC通讯」· 汇编 代码 · 共 76 行
ASM
76 行
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 + =
减小字号Ctrl + -
显示快捷键?