中文字幕无码不卡一区二区三区_少妇被又大又粗又爽毛片久久黑人_91精品国产在热久久无毒不卡_久久久久久亚洲综合网站

技術(shù)熱線: 4007-888-234
設(shè)計(jì)開發(fā)

專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命

開發(fā)工具

提供開發(fā)工具、應(yīng)用測(cè)試 完善的開發(fā)代碼案例庫分享

技術(shù)支持

從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無限潛能!

新品推廣

提供新的芯片及解決方案,提升客戶產(chǎn)品競爭力

新聞中心

提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動(dòng)態(tài)

16C5X模擬串口

更新時(shí)間: 2019-03-26
閱讀量:1666

*******************************************************************
; Plug in Libraries for the by 12 architecture *
; Written and Tested using MPASM V1.40 *
;********************************************************************
; Filename: SWUART12.ASM *
; Date: 05 November 1997 *
; File Version: 1.00 *
;********************************************************************
; Functions: *
; *
; OpenUART *
; getcUART *
; putcUART *
;********************************************************************
; Revision History: *
; V1.00 - Beta release of Peripheral Libraries *

;********************************************************************
; Notes: *
; - Change these parameters as needed and reassemble the library *
;
title "Software UART for by 12 Architecture.
list p=pic16c5x
#include
;
#define UARTPORT PORTA
#define TXPIN 3
#define RXPIN 2
#define TRISMASK 0x04
;
MODE equ 1 ; If ( X_MODE==1) Then transmit LSB first
Nbit equ 1 ; if (X_Nbit==1) # of data bits ( Transmission )
; is 8 else 7
STOPBITS equ 0 ; if Sbit2 = 0 then 1 Stop Bit else 2 Stop Bits
CLOCKSPEED equ 10
BAUDRATE equ 9600
;
; *******************************************************************
;

if UARTPORT < 5 || UARTPORT > 7
messg "Invalid port value"
endif
if RXPIN > 7
messg "Invalid rxpin value"
endif

if TXPIN > 7
messg "Invalid txpin value"
endif

; both Rx and Tx pins must be on the same port
portmask = ((0x01 << RXPIN) | TRISMASK) & ~(0x01 << TXPIN)
;
;
LSB equ 0
MSB equ 7

;***************** Communication Parameters **************************
;
ifndef MODE
MODE equ 1 ; If ( X_MODE==1) Then transmit LSB first
; if ( X_MODE==0) Then transmit MSB first ( CODEC like )
endif
ifndef Nbit
Nbit equ 1 ; if (X_Nbit==1) # of data bits ( Transmission ) is 8 else 7
endif
;
ifndef STOPBITS
STOPBITS equ 0 ; if Sbit2 = 0 then 1 Stop Bit else 2 Stop Bits
endif
ifndef CLOCKSPEED
error "CLOCKSPEED not defined"
endif
ifndef BAUDRATE
error "BAUDRATE not defined"
endif

;
;
if (CLOCKSPEED != 4 && CLOCKSPEED != 8 && CLOCKSPEED != 10 && CLOCKSPEED != 20)
error "Clockspeed not supported. Should be one of (4, 8, 10 or 20 Mhz)"
endif
if (BAUDRATE != 1200 && BAUDRATE != 2400 && BAUDRATE != 4800 && BAUDRATE != 9600)
error "Baudrate not supported. Baudrate should be one of (1200, 2400, 4800, 9600)"
endif

if CLOCKSPEED == 4
if BAUDRATE == 19200
error "Baudrate and clock speed incompatable"
endif
if BAUDRATE == 9600
BAUD_1 equ .34 ; 3+3X = CLKOUT/Baud (9600 baud, 4Mhz)
BAUD_4 equ .42 ; 3+3X = 1.25*CLKOUT/Baud
BAUD_X equ .31 ; 11+3X = CLKOUT/Baud
BAUD_Y equ .32 ; 9 +3X = CLKOUT/Baud
endif
if BAUDRATE == 4800
BAUD_1 equ .68 ; 3+3X = CLKOUT/Baud (9600 baud, 4Mhz)
BAUD_4 equ .86 ; 3+3X = 1.25*CLKOUT/Baud
BAUD_X equ .66 ; 11+3X = CLKOUT/Baud
BAUD_Y equ .66 ; 9 +3X = CLKOUT/Baud
endif
if BAUDRATE == 2400
BAUD_1 equ .138 ; 3+3X = CLKOUT/Baud (9600 baud, 4Mhz)
BAUD_4 equ .173 ; 3+3X = 1.25*CLKOUT/Baud
BAUD_X equ .135 ; 11+3X = CLKOUT/Baud
BAUD_Y equ .136 ; 9 +3X = CLKOUT/Baud
endif
if BAUDRATE == 1200
error "Baudrate and clock speed incompatable"
endif
endif
if CLOCKSPEED == 8 

if BAUDRATE == 19200
error "Baudrate and clock speed incompatable"
endi

; rest of the byte, saves it in RcvReg, *
; and sets the carry bit. *
;*****************************************************************
getcUART
clrf RcvReg ; Clear RcvReg
bcf STATUS,C ; Clear the carry bit (assume nothing rx'd)
btfsc UARTPORT,RXPIN ; check for a Start Bit

retlw 0 ; no char received.. return null.
Delay4 ; delay for 1

IF Nbit
movlw 8 ; 8 Data bits
ELSE
movlw 7 ; 7 data bits
ENDIF
;
movwf Count
R_next bcf STATUS,C
IF MODE
rrf RcvReg,f ; to set if MSB first or LSB first
ELSE
rlf RcvReg,f
ENDIF
btfsc UARTPORT, RXPIN
;
IF MODE
IF Nbit
bsf RcvReg,MSB ; Conditional Assembly
ELSE
bsf RcvReg,MSB-1

ENDIF
ELSE
bsf RcvReg,LSB
ENDIF
;
DelayY
decfsz Count,f
goto R_next
bsf STATUS,C
retlw 0x01
;
;
;*****************************************************************
; Function Name: putcUART *
; Return Value: none *
; Parameters: byte to send, in the W register *
; RAM Usage: 0 *
; ROM Usage: *

; Description: Sends the contents of the W register out *
; the TX_PIN. *
;*****************************************************************
;
putcUART
movwf XmtReg
IF Nbit
movlw 8
ELSE
movlw 7
ENDIF
movwf Count
;
IF MODE
ELSE
IF Nbit
ELSE
rlf XmtReg,f
ENDIF
ENDIF
;
bcf UARTPORT, TXPIN ; Send Start Bit
Delay1 ; 52 uS (19200 baud)
X_next bcf STATUS,C
;
IF MODE
rrf XmtReg,f ; Conditional Assembly

ELSE ; to set if MSB first or LSB first
rlf XmtReg,f
ENDIF
;
btfsc STATUS,C
bsf UARTPORT,TXPIN
btfss STATUS,C
bcf UARTPORT, TXPIN
DelayX
decfsz Count,f
goto X_next
bsf UARTPORT, TXPIN ; Send Stop Bit


伊金霍洛旗| 石嘴山市| 西城区| 怀集县| 福贡县| 犍为县| 黎平县| 称多县| 盐城市| 潜山县| 山东省| 嘉义县| 古浪县| 永定县| 普格县| 泸水县| 伊吾县| 汝南县| 门头沟区| 武功县| 娄底市| 岳阳市| 即墨市| 保亭| 富裕县| 贺兰县| 惠安县| 望城县| 邯郸市| 澄迈县| 高碑店市| 崇义县| 固阳县| 兴安盟| 安庆市| 康定县| 新乡市| 绍兴县| 韶山市| 垦利县| 扶余县|