让找料更便捷
电子元器件
采购信息平台
生意随身带
随时随地找货
一站式电子元器件
采购平台
半导体行业观察第一站
标签:
摘要: if BAUDRATE == 9600BAUD_1 equ .173 ; 3+3X = CLKOUT/Baud (9600 baud, 10MHz) BAUD_4 equ .216 ; 3+3X = 1.25*CLKOUT/BaudBAUD_X equ .170 ; 11+3X = CLKOUT/BaudBAUD_Y equ .171 ; 9 +3X = CLKOUT/Bau
if BAUDRATE == 9600
BAUD_1 equ .173 ; 3+3X = CLKOUT/Baud (9600 baud, 10MHz)
; GenerIC delay loop
Delay macro
local loop
movwf DlyCnt
loop
decfsz DlyCnt,f
goto loop
endm
; Specific delay loops... loads counter value then generic delay loop
Delay1 macro ; 3+3X = CLKOUT/Baud
movlw BAUD_1
Delay
endm
Delay4 macro ; 3+3X = 1.25*CLKOUT/Baud
movlw BAUD_4
Delay
endm
DelayX macro ; 11+3X = CLKOUT/Baud
movlw BAUD_X
Delay
endm
DelayY macro ; 9 +3X = CLKOUT/Baud
movlw BAUD_Y
Delay
endm
;
;************************ Data RAM Assignments **********************
;
udata
RcvReg res 1 ; Data received
XmtReg res 1
global RcvReg
global XmtReg
global OpenUART
global putcUART
global getcUART
udata_ovr
Count res 1 ; Counter for #of Bits Transmitted
DlyCnt res 1
;
CODE
;
;*****************************************************************
; Function Name: OpenUART *
; Return Value: none *
; Parameters: None (parameters set at assembly time) *
; RAM Usage: 0 bytes *
; ROM Usage: 4 words *
; Description: Sets the TRIS register for the UARTPORT *
; such that the RX_PIN is an input, the *
; TX_PIN is an output, and the rest of the *
; bits are as specified by TRISMASK. Also *
; sets the TX_PIN high (idle condition). *
;*****************************************************************
OpenUART
bsf UARTPORT,TXPIN ; Start it off high
movlw portmask
tris UARTPORT ; Set PWM pin for output
retlw 0
;
;*****************************************************************
; Function Name: getcUART *
; Return Value: returns a status in the carry bit (STATUS.C) *
; if a character was recieved, carry =1. *
; if no character recieved, carry = 0 *
; received character returned in RcvReg *
; Parameters: None (parameters set at assembly time) *
; RAM Usage: 0 *
; ROM Usage: depends *
; Description: looks for a start bit on the RX_PIN. If *
; none, it clears the carry bit and returns. *
; if there is a carry bit, it reads in the *
; 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
型号 | 厂商 | 价格 |
---|---|---|
EPCOS | 爱普科斯 | / |
STM32F103RCT6 | ST | ¥461.23 |
STM32F103C8T6 | ST | ¥84 |
STM32F103VET6 | ST | ¥426.57 |
STM32F103RET6 | ST | ¥780.82 |
STM8S003F3P6 | ST | ¥10.62 |
STM32F103VCT6 | ST | ¥275.84 |
STM32F103CBT6 | ST | ¥130.66 |
STM32F030C8T6 | ST | ¥18.11 |
N76E003AT20 | NUVOTON | ¥9.67 |