ON 20030927@1:50:23 AM at page:
http://www.piclist.com/techref/member/lch-YS-7A8/index.htm
lch-YS-7A8 Chao Lin edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\lch-YS-7A8\index.htm&version=0
ON 20030927@1:52:47 AM at page:
http://www.piclist.com/techref/member/lch-YS-7A8/index.htm
lch-YS-7A8 Chao Lin Says
A Serial Port Communication Program
list P= 16F84
include "P16F84.inc"
DataR equ 0x0
DataT equ 0x1
SCount equ 0x30
RBuf equ 0x31
TBuf equ 0x32
DelayConst equ 0x33
org 0x0000
goto MAIN
org 0x0015
MAIN
banksel TRISA
bsf PORTA, DataR
bcf PORTA, DataT
bcf STATUS, RP0
;----------------------------------------
DATARECEIVE
;INPUT: RBuf
clrwdt
btfsc PORTA, DataR ;Wait Start Signal
return
movlw 8 ;8 Bit Data
movwf SCount
;call DELAY
;call DELAY
RECEIVEPROC
call DELAY
rrf RBuf
bcf STATUS, C
btfsc PORTA, DataR
bsf STATUS, C
call DELAY
decfsz SCount
goto RECEIVEPROC
return
;----------------------------------------
DATATRANSMIT
clrwdt
movlw 8
movwf SCount
bcf PORTA, DataT ;Send Start Bit
TRANSMITPROC
call DELAY
call DELAY
rrf TBuf
btfsc STATUS,C
bsf PORTA, DataT ;Send 1
bcf PORTA, DataT ;Send 0
decfsz SCount
goto TRANSMITPROC
call DELAY
call DELAY
bsf PORTA, DataT
return
;----------------------------------------
DELAY
movlw 15 ;52us(baud=9600)
movwf DelayConst
DELAYLOOP
decfsz DelayConst
goto DELAYLOOP
return
;----------------------------------------
end