亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 模擬數(shù)據(jù)采器 usart.txt

?? 51單片機常用代碼
?? TXT
字號:
 
  
;Data Acquisition Device 數(shù)據(jù)采集辦法 

;* Module Description組件描述: 
;* Analog Data Acquisition模擬數(shù)據(jù)采集器組件使用 EE314 
;* 設備接口通過RS232串行口serial port到PC,同時提供協(xié)議protocol支持最多5個對;* 手方頻道 
;* oscillator clock15.36Mhz ///9600 baud rate/// 16F870
;************************************************************************
;* Revision History: 
;* 06/01/2001(GeneA): created *
;* 06/06/2001(GeneA); version 1.0 complete *
;* 06/07/2001(GeneA): A/D conversion bug. Wasn't waiting the required *
;* Tacq time between selecting the analog channel and beginning *
;* the A/D conversion. Am now delaying 16 instruction cycles prior *
;* to starting the conversion. *
;* 07/12/2001(GeneA): Version 1.1 - Changed command mapping. Read *
;* analog channel commands are now 'A' - 'E'. Verify status is now *
;* '@'. Changed the default reporting mode to ASCII. Changed the *
;* ASCII response string to include a leading character of 'a' - *
;* 'e' and a terminating character of '@'. This was to improve *
;* robustness of the protocol. Changed the Verify Status response *
;* to be a single '!' character. Added conditional assembly *
;* switches to support clock frequencies of 15.36Mhz and 18.432Mhz.* 
;************************************************************************
;
;SIMDEBUG equ 1
;DEBUG equ 1

list p=16F870 
list b=4,n=45,mm=OFF,st=OFF

#include <p16F870.inc> 
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC & _DEBUG_OFF & _LVP_OFF

cpuclk equ 18 ; use 15 for 15.36Mhz clock
; use 16 for 16.00Mhz clock
; use 18 for 18.432Mhz clock

if (cpuclk != 15) & (cpuclk != 16) & (cpuclk != 18)
error Invalid CPU CLock Frequency Specified
endif

fbSerTxInit equ 0x20 ;asynchronous, tx enabled, BRGH=0
fbSerRxInit equ 0x90 ;使能串行口, 連續(xù)發(fā)送 8bit

if cpuclk == 15
cntBaudDiv equ 24
endif

if cpuclk == 16
cntBaudDiv equ 25
endif

if cpuclk == 18
cntBaudDiv equ 29
endif

fbTrisAInit equ 0x2F ;B‘00101111’RA4 output 
fbTrisBInit equ 0x00 ; RB7-0 as output
fbTrisCInit equ 0x90 ;B‘10010000’TX,RC5 as output
; RX,RC4 as input
; RC3-0 as output

fbAdCon0Init equ 0x81 ;AD enabled, Fosc/32 clock, channel 0
fbAdCon1Init equ 0x80 ;right justified, AN4-0 as analog inputs

if cpuclk == 15
cntAdDelay equ 16 ;AD延時 
endif

if cpuclk == 16
cntAdDelay equ 18
endif

if cpuclk == 18
cntAdDelay equ 20
endif

; 命令處理的字符常數(shù)
cmdReadA0 equ 'A' ; 讀模擬通道 0 (read analog channel)
cmdReadA1 equ 'B' ; 讀模擬通道 1
cmdReadA2 equ 'C' ; 讀模擬通道 2
cmdReadA3 equ 'D' ; 讀模擬通道 3
cmdReadA4 equ 'E' ; 讀模擬通道 4
cmdVerify equ '@' ; 詢問狀態(tài)
cmdLoopBack equ 'L' ; 進入回送模式命令
chEsc equ 0x1B ; ESC - 退出回送模式
chAck equ '@' ; 確認符
chError equ '#' ; 錯誤反應符
chPrompt equ '>' ; > - 回送模式提示
chStatusOk equ '!' ; status ok. 
; 送信復位或作為對狀態(tài)命令的應答

bitModeAnalog equ 0 ;模式控制位 0 is 二進制 read back mode
; 1 is 十六進制 read back mode

VarRam equ 0x20 ; general purpose variable area
w_temp equ 0x70 ; variable used for context saving 
s_temp equ 0x71 ; variable used for context saving


cblock VarRam
bRegA ; temporary working variable
bRegB ; temporary working variable
fbMode ; 模式控制位
chCommand ; 可變的保持電流字符
achRead ; 讀模擬頻道數(shù)
bAvalL ; LSB 模擬轉變值
bAvalH ; MSB 模擬轉變值
chSend ; 連續(xù)輸出魏存器
endc

;===========================================================
ORG 0x000 
goto Main 
ORG 0x004 
goto IsrEnter
IsrEnter
movwf w_temp 
swapf STATUS,w 
movwf s_temp 

IsrExit:
swapf s_temp,w 
movwf STATUS 
swapf w_temp,f
swapf w_temp,w 
retfie 

;===========================================================
Main:
movlw 0
movwf INTCON
movwf PIR1 
movwf fbMode ; 缺省模式是 ASCII Hex 
bsf fbMode,bitModeAnalog

call InitConfig
call Delay
call Delay
call VerifyStatus

GetCommand: ; 等待下接收的一個命令字節(jié)
call GetSerialByte ; 從串行口獲得下一個字符
movwf chCommand

movf chCommand,w
andlw 0xF0
xorlw 0x40
btfsc STATUS,Z
goto DispatchCommand4X
goto InvalidCommand ; 命令字節(jié) 范圍是 0x40-0x4F.

DispatchCommand4X:
movf chCommand,w
andlw 0x0F
addwf PCL,f

goto DoCmdVerifyStatus ; 0x40 '@' - Verify status
goto DoCmdReadAnalog ; 0x41 'A' - read AN0
goto DoCmdReadAnalog ; 0x42 'B' - read AN1
goto DoCmdReadAnalog ; 0x43 'C' - read AN2
goto DoCmdReadAnalog ; 0x44 'D' - read AN3
goto DoCmdReadAnalog ; 0x45 'E' - read AN4
goto DoCmdSetBinary ; 0x46 'F' - set binary mode
goto DoCmdSetAscii ; 0x47 'G' - set ascii mode
goto DoCmdQueryMode ; 0x48 'H' - query analog mode
goto DoCmdReset ; 0x49 'I' - reset
goto InvalidCommand ; 0x4A 'J'
goto InvalidCommand ; 0x4B 'K'
goto DoCmdLoopBack ; 0x4C 'L' - enter loopback mode
goto InvalidCommand ; 0x4D 'M'
goto InvalidCommand ; 0x4E 'N'
goto InvalidCommand ; 0x4F 'O'

; 錯誤命令應答
InvalidCommand:
call SendError
goto GetCommand

;===========================================================
DoCmdVerifyStatus:
call VerifyStatus
goto GetCommand

DoCmdReset:
goto Main

;測試模式
DoCmdLoopBack:
movlw chPrompt
call PutSerialByte
call LoopBack
movlw chAck
call PutSerialByte
goto GetCommand

;讀模擬頻道
DoCmdReadAnalog:
movlw cmdReadA0
subwf chCommand,w 
movwf achRead ;and store as channel to read
call ReadAnalogChannel ;get the analog value into bAvalL
; and bAvalH
btfss fbMode,bitModeAnalog ;if clear, in binary mode
call SendAnalogBinary
btfsc fbMode,bitModeAnalog ;if set, in ASCII mode
call SendAnalogAscii
goto GetCommand

;二進制
DoCmdSetBinary:
bcf fbMode,bitModeAnalog
movlw chAck
call PutSerialByte
goto GetCommand

;十六進制
DoCmdSetAscii:
bsf fbMode,bitModeAnalog
movlw chAck
call PutSerialByte
goto GetCommand

;模擬輸出模式詢問操作. 應答'A' if in ASCII mode, and a 'B' if in binary mode
DoCmdQueryMode:
movlw 0x41 ;ASCII 'A' for ASCII mode
btfss fbMode,bitModeAnalog ;if clear, we're in binary mode
movlw 0x42 ;ASCII 'B' for binary mode
call PutSerialByte ;send the response
goto GetCommand

clrf PORTA 
clrf PORTB
clrf PORTC

bsf STATUS,RP0 ;access alternate file registers
movlw fbTrisAInit ;0X2F
movwf TRISA & 0x7F 
movlw fbTrisBInit
movwf TRISB & 0x7F 
movlw fbTrisCInit
movwf TRISC & 0x7F 
bcf STATUS,RP0 

movlw fbAdCon0Init ;0X81
movwf ADCON0
bsf STATUS,RP0
movlw fbAdCon1Init ;0X80
movwf ADCON1 & 0x7F
bcf STATUS,RP0

; 串行口異步, 波特9600
bsf STATUS,RP0 
movlw fbSerTxInit ;0X20
movwf TXSTA & 0x7F 
movlw cntBaudDiv ;9600 baud with BRGH=0
movwf SPBRG & 0x7F
bcf STATUS,RP0 ;access primary register file

movlw fbSerRxInit ;0X90
movwf RCSTA
return

;發(fā)送出錯
SendError:
movlw chError
call PutSerialByte
return

;發(fā)送應答字符
VerifyStatus:
movlw chStatusOk
call PutSerialByte
return

LoopBack:
lpbk10:
call GetSerialByte ;等待在串行口收到字符
xorlw chEsc
btfsc STATUS,Z
goto lpbk90

xorlw chEsc
call PutSerialByte
goto lpbk10

lpbk90: return 

;進行AD,值存bAvalL and bAvalH. 
ReadAnalogChannel:
movf achRead,w
movwf bRegA
rlf bRegA,f
rlf bRegA,f
rlf bRegA,f
movf bRegA,w
iorlw fbAdCon0Init
movwf ADCON0
movlw cntAdDelay ; 容許樣本保留電容變成充電 
movwf bRegA

rdac20: decfsz bRegA,f
goto rdac20
bsf ADCON0,GO_DONE ; Start the conversion

rdac40: btfsc ADCON0,NOT_DONE
goto rdac40

bsf STATUS,RP0 
movf ADRESL & 0x7F,w ;get the LSB of the result
bcf STATUS,RP0 
movwf bAvalL
movf ADRESH,w
movwf bAvalH
return


SendAnalogBinary:
movf bAvalL,w ;get the LSB
call PutSerialByte ;and send it
movf bAvalH,w ;get the MSB
call PutSerialByte ;and send it
return
;
; -------------------------------------------------------
; SendAnalogAscii
;
; This routine will send the analog value currently
; stored in bAvalL and bAvalH out the serial port. The
; data is sent as a packet with a lead character that
; will be 'a' through 'e' (to indicate which channel the
; response is for, followed by a 3 digit hex
; number in ASCII. The value is send MSB first. The 
; reponse packet is terminated by a '@' character.

SendAnalogAscii:
movf achRead,w ;get channel number
addlw 0x61 ;add Ascii 'a'
call PutSerialByte
movf bAvalH,w ;get MSB of value to send
andlw 0x0F ;mask to hex digit
call ConvertHexDigit ;turn into hex ascii digit
call PutSerialByte ;send out the serial port

movf bAvalL,w ;get LSB of value
movwf bRegA ;
rrf bRegA,f ;shift right by 4 bits to
rrf bRegA,f ; get the next digit into
rrf bRegA,f ; the correct bit positions
rrf bRegA,w
andlw 0x0F ;isolate the bits for this digit
call ConvertHexDigit ;turn into hex ascii digit
call PutSerialByte ;send out the serial port

movf bAvalL,w ;get LSB of value
andlw 0x0F ;isolate the lower hex digit
call ConvertHexDigit ;turn into hex ascii digit
call PutSerialByte ;send out the serial port

movlw chAck ; 送終止符
call PutSerialByte
return


GetSerialByte:
ifndef SIMDEBUG
gtsb10: btfss PIR1,RCIF
goto gtsb10
endif
movf RCREG,w
return

; -------------------------------------------------------
; PutSerialByte
; This routine will send a character out the serial port.
; It checks the status of the transmit buffer, and waits
; until it is clear before sending the byte.

PutSerialByte:
movwf chSend ;save output char temporarily
ifndef SIMDEBUG
ptsb10: btfss PIR1,TXIF ;wait until transmitter ready
goto ptsb10 
endif 

movf chSend,w ;send the character
movwf TXREG
return

; -------------------------------------------------------
; ConvertHexDigit
; This routine will convert the 4 bit value in W into
; an hexadecimal digit in ASCII. The result is returned
; in W.
;
; 0x0A is subtracted from the value to check if it is
; in the range 0-9 or A-F. If in the range A-F, the 
; difference between ascii 9 and ascii A is added to
; bias the result. The value of ASCII '0' is added in
; (plus the 0x0A that was subtracted in the test) to
; convert the value to an ASCII numeric digit.


ConvertHexDigit:
movwf bRegA
movlw 0x0A
subwf bRegA,w
btfsc STATUS,C ;if carry set, is in range 0-9
addlw 0x41-0x39-1 ;bias for difference between '9' and 'A'
addlw 0x30+0x0A ;convert to ASCII range
return

Delay:
movlw 255
movwf bRegA
dely20: call BitDelay
decfsz bRegA,f
goto dely20
return


; This routine delays for one bit time on the serial
; port. The delay time is 3*(n-1)+6 clocks.

cntDlyBit equ 169 
BitDelay:
movlw cntDlyBit
movwf bRegB
btdl20: decfsz bRegB,f
goto btdl20
return

;****************************************************************

end 

 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美极品aⅴ影院| 欧美不卡一区二区三区| 亚洲人成精品久久久久久| 不卡大黄网站免费看| √…a在线天堂一区| 91成人免费电影| 日本系列欧美系列| 久久网站最新地址| 成人毛片在线观看| 一区二区日韩电影| 777亚洲妇女| 国产成人在线网站| 亚洲欧美国产77777| 欧美亚洲国产怡红院影院| 日韩二区三区在线观看| 久久久久久久综合狠狠综合| 大美女一区二区三区| 亚洲精品日韩专区silk| 欧美高清精品3d| 国产美女视频一区| 亚洲激情校园春色| 精品国产伦理网| www.亚洲色图.com| 首页综合国产亚洲丝袜| 久久久久高清精品| 在线中文字幕不卡| 国产一区福利在线| 一区二区三区高清不卡| 2014亚洲片线观看视频免费| 91在线看国产| 蜜桃视频一区二区| 国产精品国产三级国产aⅴ无密码| 欧美三日本三级三级在线播放| 韩国理伦片一区二区三区在线播放| 亚洲国产精品成人综合| 6080yy午夜一二三区久久| 成人av资源在线观看| 奇米影视一区二区三区| 中文字幕在线播放不卡一区| 欧美一级xxx| 色综合久久综合网97色综合| 精品亚洲porn| 手机精品视频在线观看| 中文字幕一区日韩精品欧美| 欧美一二区视频| 在线区一区二视频| 成人黄色在线视频| 久久av中文字幕片| 日韩国产在线一| 亚洲久草在线视频| 国产精品伦理一区二区| 精品国产凹凸成av人导航| 欧美日韩五月天| 91原创在线视频| 91农村精品一区二区在线| 蜜桃精品视频在线| 亚洲国产日产av| 中文字幕一区二区三中文字幕| 欧美精品一区二区三区在线播放| 欧美剧情电影在线观看完整版免费励志电影| 粉嫩av一区二区三区在线播放 | 制服丝袜av成人在线看| 色丁香久综合在线久综合在线观看| 国产福利精品一区二区| 黄色成人免费在线| 激情深爱一区二区| 久久精品国产秦先生| 美女脱光内衣内裤视频久久影院| 午夜成人免费视频| 午夜伊人狠狠久久| 亚洲高清视频的网址| 亚洲第一综合色| 五月综合激情网| 亚洲电影一区二区三区| 亚洲一区二区3| 亚洲成a人v欧美综合天堂 | 天堂在线一区二区| 日韩国产高清影视| 久久精品国产色蜜蜜麻豆| 久久精品国产一区二区三区免费看| 日本亚洲最大的色成网站www| 亚欧色一区w666天堂| 五月婷婷综合网| 日本在线不卡视频| 极品少妇xxxx精品少妇| 国产一区 二区 三区一级| 国产电影一区二区三区| 成av人片一区二区| 色婷婷久久久久swag精品| 欧美在线综合视频| 6080国产精品一区二区| 欧美成人bangbros| 国产精品网站在线| 亚洲精品国产精华液| 国产精品久久久久久久午夜片| 久久亚洲二区三区| 亚洲国产精品传媒在线观看| 亚洲日本在线视频观看| 亚洲国产精品久久久久秋霞影院 | 欧美日韩五月天| 日韩一卡二卡三卡| 久久这里只有精品视频网| 国产精品嫩草99a| 一区二区三区成人在线视频| 青草国产精品久久久久久| 国产精品一区二区视频| 91色|porny| 91精品国产欧美日韩| 欧美国产欧美综合| 波多野结衣的一区二区三区| 欧美午夜一区二区三区| 日韩欧美一级特黄在线播放| 亚洲国产激情av| 婷婷国产在线综合| 成人综合婷婷国产精品久久蜜臀| 色94色欧美sute亚洲线路一ni | 亚洲第一狼人社区| 国产精品一卡二卡| 在线观看国产一区二区| 精品国产91久久久久久久妲己| 国产精品超碰97尤物18| 日本伊人色综合网| 99re66热这里只有精品3直播| 555夜色666亚洲国产免| 国产精品伦理在线| 免费在线视频一区| 一本久久a久久精品亚洲| 日韩美女视频在线| 一区二区三区在线观看动漫| 精品无码三级在线观看视频| 一本色道久久综合亚洲aⅴ蜜桃| 欧美不卡一区二区三区四区| 一卡二卡三卡日韩欧美| 国产精品一区在线| 日韩欧美一区在线观看| 亚洲综合免费观看高清完整版| 国产老肥熟一区二区三区| 欧美区在线观看| 亚洲美女免费在线| 国产成人在线观看免费网站| 91精品在线观看入口| 一卡二卡三卡日韩欧美| bt欧美亚洲午夜电影天堂| 久久一留热品黄| 美女视频网站黄色亚洲| 欧美色图天堂网| 亚洲欧美偷拍另类a∨色屁股| 国产精品18久久久久久久久久久久 | 色综合久久久久久久| 国产视频一区二区在线| 久久99精品国产91久久来源| 欧美男同性恋视频网站| 一区二区三区精品久久久| 91网站在线播放| 国产精品毛片a∨一区二区三区| 激情欧美日韩一区二区| 欧美成人免费网站| 蜜桃视频在线观看一区二区| 欧美四级电影网| 亚洲综合一区二区三区| 在线看不卡av| 一区二区三区在线高清| 在线亚洲高清视频| 亚洲一区二区三区不卡国产欧美| 99久久精品免费看国产| 国产精品国产三级国产三级人妇| 国产成人免费av在线| 国产欧美一区二区精品久导航| 国产在线视频一区二区三区| 欧美xxxxxxxx| 国产一区二区三区久久久| 欧美电影免费观看完整版| 久久精品国产久精国产| 精品第一国产综合精品aⅴ| 国产九九视频一区二区三区| 精品国产露脸精彩对白| 国产剧情一区二区三区| 国产精品乱码人人做人人爱 | 亚洲高清在线视频| 538在线一区二区精品国产| 免费久久99精品国产| 欧美mv和日韩mv国产网站| 国产乱理伦片在线观看夜一区| 久久精品免视看| 97精品电影院| 午夜久久久久久久久久一区二区| 在线播放欧美女士性生活| 欧美婷婷六月丁香综合色| 肉色丝袜一区二区| 精品福利一区二区三区免费视频| 国产乱码字幕精品高清av| 亚洲视频中文字幕| 91.xcao| 成人在线视频首页| 亚洲一区二区精品视频| 精品国产99国产精品| caoporn国产一区二区| 午夜视频一区在线观看| 久久久久久毛片| 欧美在线观看一二区|