
Originally Posted by
eng.alamin
you know if you use hardware UART your code will be much better in this case
i already advised you to use pic's hardware UART in my first replay
anyway any thing hard for first time don't be frustrated
i don't know which pic that you use , so i assumed that you use pic16f877a
here is small code will guide to use HARDWARE UART with pic basic pro
Code:
'small code for my friend
'eng.alamin
'------------------------
buffer var byte [10] ' your stream buffers
x var byte ' for counter
SPBRG = 12 ' 4800 clock must be 4MHz (sorry my friend but it's not inverted )
RCSTA = %10010000 ' Enable RX
TXSTA = %00100000 ' // TX
main
low porta.0 ' disable your sqaulch circuit ;)
gosub lunix
gosub pc
lunix:
if pir1.5 = 1 then ' this is the wicked :)
high porta.0 'Enable sqaulch circuit
buffer[0] = RCREG
endif
return
pc :
if PIR1.4 = 0 then pc ' wait for loading
TXREG = buffer[0] ' send data to your pc
low porta.0 ' disable your sqaulch circuit ;)
return
this program will allow you to receive only one byte and transmit it
edit and modify it according to your circuit to you have to work in loading all in coming data in buffer[x] by increasing x and adding some code line
also you can invert logic by using NPN transistor
ididn't compile this program i just worte it here
so you may find dumb mistakes
---------
regards
Bookmarks