PDA

View Full Version : Serialin timeout



Nick
- 17th April 2005, 15:10
Hi Team,

I’m using PBP 2.45a and I’m trying to get a PIC 16F628
to do some LED blinking and then go in stand by until it
receives an “OK” on the serial in or a large timeout goes by.
I’m using variable index to control this timeout.
This is how I thought of doing it but it does not seem to work (at list the
timeout part). After the initial shot on power ON it just hangs up and does nothing.

Code:

INCLUDE "bs2defs.bas"
@ device pic16F628, intrc_osc, wdt_on, pwrt_on,mclr_off,protect_off



red VAR PORTB.4
green VAR PORTB.5
serial_in VAR PORTB.0
password VAR BYTE
index VAR BYTE

cmcon=7
TRISB=%10000001
Pause 1000

loop:
index=0
High red
Pause 500
High green
Pause 500
Low red
Pause 500
Low green

main_loop:
index=index+1
SerIn serial_in,T2400,100,again,["O"],password
IF password="K" Then
GoTo loop
Else
again:
IF index>99 Then
GoTo loop
Else
GoTo main_loop
EndIF
EndIF

End
Any ideas what I’m doing wrong?
Thank you for your attention.

NavMicroSystems
- 17th April 2005, 15:26
Nick,

since you haven't told us which device is sending the "OK"
and I don't know what your schematic looks like,
all I can do is guessing.

It Looks like your SERIN never times out.
are you sure T2400 is the correct mode?
Try N2400.

Search the board for SERIN or SERIN2 you'll find many examples.

Nick
- 17th April 2005, 17:13
Hi Ralph,
Thank you for your input
I'm using an other PIC to send the "OK" with the Serout T2400 mode.
This part works.
I'm having problems with the SerIn timeout only.
I will also try the search.

mister_e
- 17th April 2005, 20:08
Also look to your config fuse... there's a error. You should use MCLRE_OFF instead or tie your MCLR pin to VDD

Nick
- 17th April 2005, 23:09
Thanks Team.
I made the suggested changes and some resoldering and it all works now.
Thank you again.

mister_e
- 18th April 2005, 15:21
You're welcome.