PDA

View Full Version : 16f877a serin help!



stu746
- 17th December 2004, 16:28
hi I can not get this code to work on a 16f877a, it sends the text to the pc fine but will not recieve anything from the pc!?

so i tried it on a 16f628 and it worked fine! with everything the same?


ADCON1 = 7 ' PORTA and E digital


Include "modedefs.bas" ' Include serial modes

B0 var byte
symbol led = portb.2

high led
pause 500
low led
pause 500
serout porta.1,396,["READY......"]

loop: Serin porta.0,396,B0 ' B0 = input character
If (B0 < "a") or (B0 > "z") Then print ' If lower case, convert to upper
B0 = B0 - $20
print: Serout porta.1,396,[B0] ' Send character
Goto loop ' Forever

Dwayne
- 17th December 2004, 16:56
Hello Stu746,

Stu>>so i tried it on a 16f628 and it worked fine! with everything the same?


ADCON1 = 7 ' PORTA and E digital<<

Take a look at FAQ Serin/Serout.

Are your ports all outputs?
TRISB=00000000?
and TRISA =00000001

Are you using the correct baudrates (start slow..2400)?.. Inverted? Parity?



Can you verify your data coming from your PC? Scope it?
Wrong

Bruce
- 17th December 2004, 21:09
1. For the 16F628 you would need CMCON = 7 to setup RA as digital. It doesn't hurt to use this with the F877A part either. Even though the F877A POR default is CM2:CM0 = 111 it never hurts to make 100% sure.

2. You're using the wrong baud mode for SERIN. 396 would be used for SERIN2 @ 2400 bps, driven, true.

For SERIN you would use mode 0 or --

Serin porta.0, 0, B0 ' B0 = input character

Or, since you're already using Include "modedefs.bas" --

Serin porta.0, T2400, B0 ' B0 = input character

stu746
- 18th December 2004, 13:35
thanks for the replies

it was a 16f877 i tried first, i just tried with a 16f877a and it worked fine!?

i will stick to the a version from now

zikha
- 10th January 2006, 16:20
hi stu.
i think i am looking for the code you are mentioning. i need to send data from pic16f877a to pc via rf module named RXB4411S-434mhz. you say that it work. would you mind sending me the code for initiating the connection and sending data from the transmitter to receiver. thank you