PIC PIC 16F84 rs485 na rutinsko

RS485_RX.bas

'************************************************* **
'***** Mbyka - (c) Copyright 2002 **********
'************************************************* **
'RS485 comminications
'TX

uključiti "modedefs.bas"

datap var porta.0
dir var porta.1 'dir = 1 then output, dir = 0 onda unosa
led1 var portb.0
led2 var portb.1
veri var byte
Baud con 84'9600, N, 8,1start:
trisa = 1
trisb = 0
led1 = 0
led2 = 0
glavni:
dir = 0
serin2 datap, Baud, 100, glavni, [veri]
led1 = 1
stanka 150
led1 = 0
'
ako veri = "X", a zatim
led2 = 1
stanka 150
led2 = 0
endif
goto glavni

 
RS485_TX.bas

'************************************************* **
'***** Mbyka - (c) Copyright 2002 **********
'************************************************* **
'RS485 commminications
'TX

uključiti "modedefs.bas"

datap var porta.0
dir var porta.1 'dir = 1 then output, dir = 0 onda unosa
buton var portb.0
vodio var portb.1
veri var byte
Baud con 84'9600, N, 8,1start:
trisa = 0
trisb = 1
vodio = 0
glavni:
ako buton = 1 then
poziv rs485_send
endif
stanka 150
goto glavnirs485_send:
vodio = 1
dir = 1
serout2 datap, Baud, [ "X"]
vodio = 0
povratak

************************************************** ***

SHIFTOUT.bas'************************************************* **
'***** Mbyka - (c) Copyright 2002 **********
'************************************************* **
'74HC595 Kullanımı

uključiti "modedefs.bas"

OE var portc.0
sclk var portc.1
sdat var portc.2
veri var byte

Start:
trisc = 0
portc = 0
Glavno:
veri = $ 12
shiftout sdat, sclk, LSBFIRST, [veri]
OE = 0
OE = 1
OE = 0
obavlja:
@ Spavanja
učinjeno goto

 

Welcome to EDABoard.com

Sponsor

Back
Top