|
|
View previous topic :: View next topic |
Author |
Message |
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
Getc using timeout feature problems |
Posted: Mon Jul 25, 2005 8:56 am |
|
|
Hi,
Is there a better way for getc to timeout after some time, the one given in CCS example seems to make the PIC go haywire...
Also what value of delay time should I use for 1200 bits/sec
thanks
arunb |
|
|
Ttelmah Guest
|
|
Posted: Mon Jul 25, 2005 3:44 pm |
|
|
Personally, I just use a interrupt driven receive, and a hardware timer set to the interval I require.
The bps rate, only has a small bearing on the timout interval, unless you are looking to send all characters 'nose to tail' without pauses.
You need to be looking at your own timings throughout the system, likely reasons for gaps, and how you want to recover.
For instance, in another situation, I deal on a 'packet' basis, the serial just scans looking for an STX character, and when this is received, assumes a packet is starting. The packet is 16 characters, plus a header, checksum and ETX charater. The data is sent over a wireless link, with a 50mSec 'turnround'. When STX is seen, it implies the link should be in receive mode, and the packet should follow. However the PC at the other end, is quite capable of being multi-tasking, and taking perhaps a 18mSec break at some point in the output. Hence I allow 20 character times (in my case at 9600bps, 20.1mSec), plus the possibility of another 18mSec break, to give a total time of 38.1 mSec in which a packet should be completed. I use 40mSec, and only if this has passed without the packet completing, then restart scanning, and trigger a new request for data.
On the PC itself, the timeout value if used, is normally set to 10mSec plus the character time.
So, you need to be thinking what the worst case 'legitimate' break is, and trigger the timeout after this interval.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|