PDA

View Full Version : how to use SERIN???



texas5
- 22nd September 2008, 23:00
i try to send data from vb to pic16f877a using serial port.can i use those code below???

code:

SO con 0 ' Define serial out pin
SI con 1 ' Define serial in pin
N2400 con 4 ' Set serial mode
B0 var byte

loop:
Serin SI,N2400,B0 ' B0 = input character
If (B0 < "a") or (B0 > "z") Then print ' If lower case, convert to upper
B0 = B0 - $20

print:
Serout SO,N2400,[B0] ' Send character
Goto loop ' Forever

can someone teach me how to setting the:

SO con 0 ' Define serial out pin
SI con 1 ' Define serial in pin
N2400 con 4 ' Set serial mode
B0 var byte

i use pic16f877a which the rx=portc.7 and tx=portc.6...

mackrackit
- 22nd September 2008, 23:10
If you want to name a pin use var


SO VAR PORT?.?

And you will need [] in your SERIN statement.

And if you are using the software serial (SERIN, SERIN2) then any pin will work if it is digital, pretty much.

texas5
- 22nd September 2008, 23:30
for example:

SO VAR portc.6 'tx pin for pic16f877a
SI VAR portc.7 'rx pin for pic16f877a

SERIN SI,N2400,["A"],B0 'Wait until the character “A” is received serially

am i correct???

mackrackit
- 22nd September 2008, 23:48
That should do the trick

texas5
- 23rd September 2008, 00:03
thanx...i will try it.