View previous topic :: View next topic |
Author |
Message |
Tuga
Joined: 21 Aug 2007 Posts: 6
|
Change time limit for RS232 |
Posted: Tue Oct 23, 2007 5:39 am |
|
|
Hello,
I'm using the pic18f4455 with module ethernet tibbo em202, but i need communication adapt to the current state of the network.
How i can change the timeout the RS232 when my PIC work's?
Thanks |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Oct 23, 2007 6:27 am |
|
|
Sorry, I don't understand your question. RS232 describes the hardware connection, it is not a protocol and knows nothing about time-outs. |
|
|
Tuga
Joined: 21 Aug 2007 Posts: 6
|
|
Posted: Tue Oct 23, 2007 6:55 am |
|
|
The timeout is specified in the #use rs232 statement as shown below. I use this code to define the time limit to receive data in rs232 (50ms to wait):
Code: |
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, ERRORS, TIMEOUT=50)
void putnet( char c )
{
putc(c);
}
char getnet()
{
return(getc());
}
|
However I do not know change this time with the PIC in operation, but would like to have access to this variable.
It's possible change this variable with the PIC in operation?
Thanks |
|
|
Ttelmah Guest
|
|
Posted: Tue Oct 23, 2007 8:47 am |
|
|
Simple answer, don't use the timeout in the #use RS232, but do a search for 'timed_getc'. Since this function then comes under your control, you can change the timeout as you want.
You can change the timing, by having multiple streams with different timeouts defined, but is is bulkier and less flexible than going DIY.
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Oct 23, 2007 8:49 am |
|
|
See ex_tgetc.c in the examples directory of the CCS compiler for how you can write your own time out version of getc. You could modify this example to accept a second parameter specifying the timeout value, or change it into a global variable. |
|
|
Tuga
Joined: 21 Aug 2007 Posts: 6
|
|
Posted: Thu Oct 25, 2007 4:33 am |
|
|
Thank you all for your good advise.
I still have to make some progress in the project, when finished, I leave the solution chosen. |
|
|
|