![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
TomD Guest
|
Serial Timeout |
Posted: Mon Feb 19, 2007 6:26 pm |
|
|
Hi all.
I'm new here, so please excuse what may a previously discussed topic. A quick search didn't reveal much help. Here goes ..
I have a narrow time slot (50 ms) to send a 5 byte message to another PIC, get a 5 byte response, and then move on.
I'm need to use a software UART, as my hardware UART is taken for other uses. I'm running at 19,200 baud, or about 2 bytes per mS.
I need to avoid the situation where I send a message and then get hung waiting for a response that may not ever come. I have a 1 mS hardware timer running in the background, but I'm not sure if I need to disable it while using the software UART.
The PIC Basic language has a timeout argument that can be passed to the equiv of the getc(). Is there such a thing in the C world?
Thanks in advance.
Tom |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 19, 2007 7:54 pm |
|
|
If you have vs. 4.xxx of the compiler, the manual says that #use rs232()
now supports a TIMEOUT feature which will do exactly what you want.
I haven't tested this. I don't know if it's been implemented yet.
For earlier versions of the compiler, CCS has a timed_getc() function.
Here's the file location: c:\Program Files\Picc\Examples\Ex_Tgetc.c
I'm not certain if it will work with a soft UART. I'd have to look at the
.LST file to see the delay between the time kbhit is found and the time
the soft UART code starts executing. This delay would be due to the
code required to run the timeout loop. The CCS example uses the
hardware UART. It would have to be tested with a software UART.
If you want to do this, go ahead. |
|
![](templates/subSilver/images/spacer.gif) |
tomd Guest
|
|
Posted: Mon Feb 19, 2007 8:59 pm |
|
|
thanks .. that's what I needed. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|