CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Serial Timeout

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
TomD
Guest







Serial Timeout
PostPosted: Mon Feb 19, 2007 6:26 pm     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 19, 2007 7:54 pm     Reply with quote

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.
tomd
Guest







PostPosted: Mon Feb 19, 2007 8:59 pm     Reply with quote

thanks .. that's what I needed.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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