📄 t2.asm
字号:
;test program for HID ballast
;writer: Cecilia Chen
;2008.08.21
;PIC16F690 半双工 同步 从模式 波特率9600HZ
list p=16f690
#include p16f690.inc
#include<t2.inc>
__config _FCMEN_OFF&_IESO_OFF&_BOR_OFF&_CPD_ON&_CP_ON&_MCLRE_OFF&_PWRTE_OFF &_WDT_OFF&_INTRC_OSC_NOCLKOUT
extern init, serial
CODE
org 0x00
goto main
org 0x04
goto timeout
;delay-------------------------------------------------------------------------
delay1
clrf del_temp1
loop1
decfsz del_temp1
goto loop1
return
delay
clrf del_temp2
loop
call delay1
decfsz del_temp2
goto loop
return
;delay end-------------------------------------------------------------------
;timeout----------------------------------------------------------------------
timeout
BANKSEL 0x00
bcf PIR1,TMR1IF
bcf T1CON,TMR1ON
movlw t1low
movwf TMR1L
movlw t1hi
movwf TMR1H
bsf T1CON,TMR1ON
decfsz t_count
retfie
BANKSEL 0x00
bsf t_flag,0
movlw 0x0A
movwf t_count
retfie
;timeout end----------------------------------------------------------------
;ADtrans---------------------------------------------------------------------
ADtrans
;ad_count==3?
movlw 0x03
subwf ad_count,0
btfsc STATUS,Z
goto next ;ad_count==3
BANKSEL 0x80
bsf ADCON0, 1
call delay1
movlw 2*ad_count
addlw buffer
movwf FSR
movf ADRESH, 0
movwf INDF
incf FSR
movf ADRESL, 0
movwf INDF
next
BANKSEL 0x00 ;ad_count!=3
movf ADCON0, 0
addlw 0x04
movwf ADCON0
incf ad_count
bcf t_flag,0
;ad_count>9?
movf ad_count
sublw 0x09
btfsc STATUS,C
return ;ad_count<=9
clrf ad_count ;ad_count>9
return
;ADtrans end-----------------------------------------------------------------
;main---------------------------------------------------------------------------
main
movlw 0x01
movwf OwnAddress
call init
bsf T1CON,TMR1ON
cyc
call serial
btfss t_flag,0
goto cyc ;t_flag.0==0
call ADtrans ;t_flag.0==1
goto cyc
end
;main end---------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -