View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 21, 2005 3:22 pm |
|
|
Quote: | #int_rda
void RDA_isr()
{
char c[20];
int dir=0;
do
{
gets(c); |
Do you know that the gets() function waits in a loop, while it looks
for a carriage return character (0x0D) to mark the end of a received
string ? So your code will get one interrupt, and then jump to the
#int_rda routine, and then just sit inside it, until you press the Enter key.
It seems to me that if you're using gets(), then there is no need for
the #int_rda routine. Just put gets() in your main() code. |
|
|
JEliecer
Joined: 08 Feb 2005 Posts: 17 Location: Bucaramanga - Colombia
|
|
Posted: Thu Apr 21, 2005 6:42 pm |
|
|
The routine to receive strings for the RS232, alone it is a part of my program.
This code that I place in the forum is a test to know how works the data reception by the RS 232.
My main program is a timer of real time and it can be programmed by the RS232 or by keyboard. Also, in all moment it should show the state of the variables.
My problem with the RS232, is that I cannot visualize the received data, when I keep them in the PIC memory.
Please. I need to know:
How I can save the strings in the eeprom.?
I have others values in the eeprom and place it here whit
write_eeprom(address,data)
But, when I use write_eeprom(x,y),it don't function me with the rs232 routine. _________________ Jorge Eli�cer Castro
"THE UNIVERSE FOREVER CONSPIRES SO THAT OUR DESIRES ARE WILL BE REALITY"
"EL UNIVERSO SIEMPRE CONSPIRA PARA QUE NUESTROS DESEOS SE HAGAN REALIDAD" |
|
|
JEliecer
Joined: 08 Feb 2005 Posts: 17 Location: Bucaramanga - Colombia
|
Routine for Rs232 |
Posted: Fri Apr 22, 2005 7:46 am |
|
|
If I put gets() in my main() code, it will be executed in every cycle of the forever loop...????
My program has many more instructions, and these should be executed in every cycle of the forever loop.
How I can place the gets() in my main(), in such way that alone it is executed when the data will be in the buffer of the rs232.? _________________ Jorge Eli�cer Castro
"THE UNIVERSE FOREVER CONSPIRES SO THAT OUR DESIRES ARE WILL BE REALITY"
"EL UNIVERSO SIEMPRE CONSPIRA PARA QUE NUESTROS DESEOS SE HAGAN REALIDAD" |
|
|
sseidman
Joined: 14 Mar 2005 Posts: 159
|
Re: Routine for Rs232 |
Posted: Fri Apr 22, 2005 8:10 am |
|
|
JEliecer wrote: | If I put gets() in my main() code, it will be executed in every cycle of the forever loop...????
My program has many more instructions, and these should be executed in every cycle of the forever loop.
How I can place the gets() in my main(), in such way that alone it is executed when the data will be in the buffer of the rs232.? |
My approach would be to use getc (not gets) in the RDA interrupt to fill a string buffer, and set a flag in the interrupt when a CR is detected. Your main should check on that flag, do what processing it needs to do, and then clear the string buffer and the CR flag.
Scott |
|
|
JEliecer
Joined: 08 Feb 2005 Posts: 17 Location: Bucaramanga - Colombia
|
Routine for RS232 |
Posted: Fri Apr 22, 2005 7:46 pm |
|
|
What is kbhit() ???
How I can use it...??
Can I call this function in the #int_rda routine, How I can do it...??? _________________ Jorge Eli�cer Castro
"THE UNIVERSE FOREVER CONSPIRES SO THAT OUR DESIRES ARE WILL BE REALITY"
"EL UNIVERSO SIEMPRE CONSPIRA PARA QUE NUESTROS DESEOS SE HAGAN REALIDAD" |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Fri Apr 22, 2005 7:55 pm |
|
|
From the manual
Quote: | If the RS232 is under software control this function
returns TRUE if the start bit of a character is being sent
on the RS232 RCV pin. If the RS232 is hardware this
function returns TRUE is a character has been received
and is waiting in the hardware buffer for getc() to read.
This function may be used to poll for data without
stopping and waiting for the data to appear. Note that in
the case of software RS232 this function should be
called at least 10 times the bit rate to ensure incoming
data is not lost.
|
It is used to tell if there is an incoming char. You do not need it with int_rda since the interrupt is triggered by a char being ready in the UART buffer. You only need it if you do not use interrupts or you are using a software UART.
Note the info says you need to poll at 10 TIMES the bit rate.
See the example on page 115 of the manual for how it is used. |
|
|
JEliecer
Joined: 08 Feb 2005 Posts: 17 Location: Bucaramanga - Colombia
|
Routine for RS232 |
Posted: Sat Apr 23, 2005 7:53 am |
|
|
Where is the ccs manual.
Can you send me it to [email protected].
Thanks by your help. _________________ Jorge Eli�cer Castro
"THE UNIVERSE FOREVER CONSPIRES SO THAT OUR DESIRES ARE WILL BE REALITY"
"EL UNIVERSO SIEMPRE CONSPIRA PARA QUE NUESTROS DESEOS SE HAGAN REALIDAD" |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
Use the link below |
Posted: Sat Apr 23, 2005 8:14 am |
|
|
You find it on the CCS downloads page. Below is the link.
http://www.ccsinfo.com/download.shtml
BTW, I was off by one page. They are 114 AND 115. |
|
|
JEliecer
Joined: 08 Feb 2005 Posts: 17 Location: Bucaramanga - Colombia
|
Routine for RS232 |
Posted: Wed Apr 27, 2005 8:20 pm |
|
|
Hi,
I'm ready. I have a complete routine for receive strings and save it in the eeprom.
Thanks to everybody.
Until soon. _________________ Jorge Eli�cer Castro
"THE UNIVERSE FOREVER CONSPIRES SO THAT OUR DESIRES ARE WILL BE REALITY"
"EL UNIVERSO SIEMPRE CONSPIRA PARA QUE NUESTROS DESEOS SE HAGAN REALIDAD" |
|
|
|