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

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

?? 模擬數據采器 usart.txt

?? 單片機開發源代碼集錦 31例
?? TXT
字號:
 
  
;Data Acquisition Device 數據采集辦法 

;* Module Description組件描述: 
;* Analog Data Acquisition模擬數據采集器組件使用 EE314 
;* 設備接口通過RS232串行口serial port到PC,同時提供協議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 ;使能串行口, 連續發送 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

; 命令處理的字符常數
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 '@' ; 詢問狀態
cmdLoopBack equ 'L' ; 進入回送模式命令
chEsc equ 0x1B ; ESC - 退出回送模式
chAck equ '@' ; 確認符
chError equ '#' ; 錯誤反應符
chPrompt equ '>' ; > - 回送模式提示
chStatusOk equ '!' ; status ok. 
; 送信復位或作為對狀態命令的應答

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 ; 讀模擬頻道數
bAvalL ; LSB 模擬轉變值
bAvalH ; MSB 模擬轉變值
chSend ; 連續輸出魏存器
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: ; 等待下接收的一個命令字節
call GetSerialByte ; 從串行口獲得下一個字符
movwf chCommand

movf chCommand,w
andlw 0xF0
xorlw 0x40
btfsc STATUS,Z
goto DispatchCommand4X
goto InvalidCommand ; 命令字節 范圍是 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

;發送出錯
SendError:
movlw chError
call PutSerialByte
return

;發送應答字符
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一区二区三区免费野_久草精品视频
99久久er热在这里只有精品15| 国产清纯白嫩初高生在线观看91| 久久蜜桃av一区精品变态类天堂| 日本亚洲欧美天堂免费| 欧美日韩国产高清一区| 丝袜国产日韩另类美女| 日韩欧美中文一区| 国产成人午夜99999| 最近日韩中文字幕| 欧美日韩精品欧美日韩精品| 欧美色涩在线第一页| 国产黄色91视频| 成人教育av在线| 久久疯狂做爰流白浆xx| 亚洲视频一区二区免费在线观看| 国产欧美一区二区三区网站| 中文文精品字幕一区二区| 激情综合网最新| 依依成人综合视频| 欧美大胆一级视频| 欧美无人高清视频在线观看| 国产成人99久久亚洲综合精品| 午夜一区二区三区视频| 91精品国产全国免费观看| www.色综合.com| 国产精品一区二区三区乱码| 伊人开心综合网| 日韩中文字幕亚洲一区二区va在线| 热久久国产精品| 天天亚洲美女在线视频| 狠狠色丁香久久婷婷综合_中 | 亚洲男人都懂的| 精品sm在线观看| 欧美日韩在线播放一区| 欧美大片在线观看| 成人欧美一区二区三区1314| 国产女人18毛片水真多成人如厕| 亚洲美女免费视频| 国产精品99久久久久久宅男| 欧美自拍偷拍一区| 91久久线看在观草草青青| 成人在线综合网| 国产激情偷乱视频一区二区三区| 在线观看日韩电影| 国产色产综合色产在线视频| 久久亚洲精品小早川怜子| 久久婷婷一区二区三区| 亚洲一区中文在线| 亚洲一区二区三区影院| 成人免费va视频| 精品国产伦一区二区三区观看方式 | 99久久综合精品| 欧美xxx久久| 欧美—级在线免费片| 免费视频一区二区| 欧美日韩一区三区四区| 亚洲色图欧洲色图| 国产成a人无v码亚洲福利| 日韩视频123| 亚欧色一区w666天堂| 色综合久久综合网欧美综合网| 91毛片在线观看| 色综合av在线| 欧美激情综合五月色丁香小说| 久久精品理论片| 日韩精品中午字幕| 丝袜亚洲另类欧美综合| 欧美日韩精品欧美日韩精品| 亚洲与欧洲av电影| 欧美中文字幕一二三区视频| 亚洲少妇屁股交4| 一本久道中文字幕精品亚洲嫩| 亚洲国产精品国自产拍av| 国产成人欧美日韩在线电影| 久久久亚洲高清| 国产精品99久久久久久似苏梦涵| 精品久久国产老人久久综合| 国产在线精品一区二区| 91免费视频观看| 亚洲欧洲一区二区三区| 色悠久久久久综合欧美99| 亚洲丝袜美腿综合| 91福利精品第一导航| 亚洲一卡二卡三卡四卡| 欧美日韩的一区二区| 秋霞成人午夜伦在线观看| 精品国一区二区三区| 国产精品99久久久久| 国产欧美日本一区视频| 97精品视频在线观看自产线路二| 亚洲欧美怡红院| 欧美亚洲国产bt| 久久精品国产网站| 国产精品网站导航| 欧美亚洲动漫制服丝袜| 青青草91视频| 中文字幕二三区不卡| 日本精品视频一区二区三区| 午夜av电影一区| 亚洲国产成人一区二区三区| 欧美综合一区二区| 精品一区二区三区av| 欧美极品aⅴ影院| 国产麻豆视频精品| 一个色妞综合视频在线观看| 国产精品91一区二区| 亚洲欧美另类小说视频| 欧美成va人片在线观看| 91色综合久久久久婷婷| 九九国产精品视频| 亚洲老妇xxxxxx| 欧美一区二区观看视频| 99精品视频在线免费观看| 久久精品久久99精品久久| 中文字幕亚洲欧美在线不卡| 6080国产精品一区二区| 午夜影视日本亚洲欧洲精品| 国产视频不卡一区| 91精品中文字幕一区二区三区| 国产超碰在线一区| 日韩 欧美一区二区三区| 中文字幕在线播放不卡一区| 日韩美女在线视频| 欧美猛男gaygay网站| 一区二区激情小说| 久久精品亚洲一区二区三区浴池| 欧美三级视频在线观看| 成人性生交大片| 久久成人18免费观看| 亚洲va国产天堂va久久en| 国产精品对白交换视频| 91女神在线视频| 国产精品一线二线三线| 麻豆极品一区二区三区| 久久综合久久综合久久综合| 欧美日韩亚洲国产综合| 色欧美片视频在线观看在线视频| 国产高清无密码一区二区三区| 奇米色777欧美一区二区| 亚洲第一久久影院| 亚洲麻豆国产自偷在线| 中日韩免费视频中文字幕| 久久久久久久久久看片| 精品国产乱码久久久久久影片| 宅男在线国产精品| 91.com在线观看| 在线不卡中文字幕播放| 欧美久久久久久久久| 在线综合视频播放| 日韩女优毛片在线| 欧美精品一区二区三区视频| 日韩欧美视频在线| 精品国产3级a| 国产亚洲欧美一区在线观看| 久久精品人人做人人爽人人| 国产人成一区二区三区影院| 国产精品嫩草影院av蜜臀| 国产精品理论片| 一区二区三区在线观看国产| 亚洲一区在线播放| 奇米一区二区三区av| 国产做a爰片久久毛片| 国产一区二区在线电影| 高清在线观看日韩| 99re热这里只有精品视频| 色94色欧美sute亚洲线路一久| 91福利国产成人精品照片| 欧美日韩成人在线一区| 欧美www视频| 国产精品久久久久国产精品日日| 亚洲乱码日产精品bd| 天天av天天翘天天综合网色鬼国产| 日韩二区三区四区| 国产成a人无v码亚洲福利| 91国偷自产一区二区使用方法| 91麻豆精品国产综合久久久久久| 精品久久人人做人人爱| 中文字幕一区二区三区视频| 亚洲成av人片在www色猫咪| 极品尤物av久久免费看| 91浏览器在线视频| 欧美一级黄色片| 国产精品成人一区二区三区夜夜夜| 尤物av一区二区| 国产精品香蕉一区二区三区| 在线观看日韩高清av| 久久婷婷一区二区三区| 一区二区三区日韩欧美| 国产一区二区三区电影在线观看| 91在线国产福利| 久久夜色精品一区| 亚洲v日本v欧美v久久精品| 国产精品影视在线观看| 欧美日韩亚洲另类| 日韩理论片在线| 国产精品一区免费视频| 欧美丝袜丝交足nylons图片| 日本一区二区三区高清不卡| 图片区日韩欧美亚洲| 91在线视频免费观看|