PDA

View Full Version : Problem with serin2 serout2



jasem700
- 4th March 2009, 17:37
Hi for all friend


with serial communication between two 16F84A I send a varible b0 from firt To second pic
code :
MAIN:
FOR B0=4 T0 200
SEROUT2 0,T9600,[DEC1 b0]
PAUSE 10
NEXT BO

GOTO MAIN

the second pic recieved only first byte B0=4 BY


SERIN2 0,T9600,[DEC1 b0]

but why second pic can't recieved variable from 4 TO 200

I USE OSC 4MHZ
THANK YOU FOR YOUR INTERSTING

Bruce
- 4th March 2009, 17:47
Have you tried [DEC b0] on both ends?

jasem700
- 5th March 2009, 17:55
yes i try [DEC b0] but nothing changed pic recieved only first byte

aratti
- 5th March 2009, 18:28
SEROUT2 0,T9600,[DEC1 b0]

To use 9600,n,8,1 with Serin2/Serout2, code should be:


SEROUT2 Pin,84,[DEC b0]
SERIN2 Pin,84,[b0]


What does your program after the serin2 with the byte received? Very likely the second byte arrives when receiver is not yet ready, increase the Pause to 1000 and see if it works than reduce it gradually to the optimum.

Al.

Bruce
- 5th March 2009, 21:44
DEC causes numbers to be sent in ASCII format. 1 to 9 will work fine since each number will
be a single ASCII character. When you get to 10, it sends an ASCII 1 followed by an ASCII
0, which requires two bytes. DEC 100 will be 3 ASCII bytes, etc.

Try something like this;


T9600 CON 84

MAIN:
FOR B0=4 T0 200
SEROUT2 0,T9600,[B0] ' without modifier, sends the unformatted byte value of 4 to 200
PAUSE 10
NEXT BO

SERIN2 0,T9600,[B0] ' can receive a value from 0 to 255

jasem700
- 6th March 2009, 18:55
hi all my friends

thank you for your reply

yes Mr ARATTI it's works good with

SEROUT2 Pin,84,[DEC b0]
Pause 100
SERIN2 Pin,84,[b0]

thank you very much and thanks for Mr Bruce
Although I don't try yet his code

good luck