PDA

View Full Version : Serin woes



Libretto
- 9th November 2004, 10:06
Hello there,

I am having problems with the 'serin' command. I have searched this and the MELabs forum about this problem. I have read about the timeout part of serin and the need for a pull down resistor etc...

At work, the line of code below has been used with no problems. (The preamble is correctly detected and the data stored).

Serin portc.7,N9600,["ZOM"],z,zc,f,fc

But when I try to use the timeout options, eg:

Serin portc.7,N9600,20,fail,["ZOM"],z,zc,f,fc

It appears the preamble is ignored, so the data is never recovered. Of course the timeout and fail routine works correctly. So somehow the timeout part conflicts with the preamble??

Any ideas? Suggestions welcome.

P.S.: Trying on 16F870 and PBP v2.43

Dwayne
- 9th November 2004, 14:31
Hello Libretto,

Libretto>>Any ideas? Suggestions welcome<<

Try increasing your timeout to 500 instead of 20. If that doesn't work, try decreasing your transmit time from 9600 to 4800 to see if a slower speed works

Dwayne

Libretto
- 9th November 2004, 14:49
Thanks again, changed the crystal to 10MHz and the extended code works!

Thanks for the suggestions.

Well I've tried various timeouts (upto a few seconds) with no change in results.

I understand that 9k6 timing on a 4MHz crystal is a little dodgy, so maybe the extra timeout code is upsetting the system. Can't easily go to a lower baud rate as the serial sender is a built unit. But will see if a different version can be found, or even speed up the crystal in my circuit.

Bruce
- 9th November 2004, 19:32
Have you tried using SERIN2 or DEBUGIN..?

See what happens with something like this:

DEFINE DEBUGIN_REG PORTC
DEFINE DEBUGIN_BIT 7 ' Use RC7
DEFINE DEBUGIN_BAUD 9600
DEFINE DEBUGIN_MODE 1 ' Inverted

DEBUGIN 20,fail,[WAIT("ZOM"),z,zc,f,fc]

I have found (on several occasions) that just using a different serial input type/command does the trick.

Libretto
- 11th November 2004, 09:45
Again many thanks, the serin2 verion worked at 4MHz.