PDA

View Full Version : 16F877 PC communucation



batajrberk
- 16th December 2010, 16:54
Hi guys, i have a problem. I connected the pc and the pic want to get same values from the PC. I send my data in shape " A+B0C1D2 " and at the end want to have +012. At the same time in the code, i use
HSERIN[Wait(A),RX]
sign = RX
HSERIN[Wait(B),RX]
b1 = RX
HSERIN[Wait(C),RX]
b2 = RX
HSERIN[Wait(D),RX]
b3 = RX
Eventhough, the pic gets A,B,C,D, when i put the chars on LCD i get nothing. What shoud i do ? Please help... Thx

mackrackit
- 16th December 2010, 17:14
Welcome to the forum.

When using the serial hardware ports an inverter chip or circuit is needed between the PIC and PC, (MAX232)..
PC hardware sends/receives inverted data
PIC hardware sends/receives true data

And the DEFINES for HSERIN/HSEROUT need set in your code.

You may want to use SERIN2 to get started. SREIN2 is a bit banging approach that can receive inverted data.

batajrberk
- 16th December 2010, 18:20
Thx for your reply:) im already using max232 and already wrote the define lines as;

define hser_baud 4800
DEFINE HSER_RCSTA 90h '(alma yazmacının Enable edilmesi)
DEFINE HSER_TXSTA 20h

But there is nothing. what am i supposed to do ?

Darrel Taylor
- 16th December 2010, 20:03
Use all UPPERCASE letters in your define's.

define HSER_BAUD 4800

batajrberk
- 17th December 2010, 00:12
Thx for your reply but thats not the problem. I somehow solved it by using

HSERIN[Wait(A), SKIP \3]
HSERIN[RX]
b1 = RX

Although, i dont know how adding "SKIP \3" solved my problem now its working. I just wonder now if anyone know how this worked ?