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 CCS Technical Support

Routine for RS232
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 21, 2005 3:22 pm     Reply with quote

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

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Thu Apr 21, 2005 6:42 pm     Reply with quote

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

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

Routine for Rs232
PostPosted: Fri Apr 22, 2005 7:46 am     Reply with quote

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

View user's profile Send private message

Re: Routine for Rs232
PostPosted: Fri Apr 22, 2005 8:10 am     Reply with quote

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

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

Routine for RS232
PostPosted: Fri Apr 22, 2005 7:46 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Apr 22, 2005 7:55 pm     Reply with quote

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

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

Routine for RS232
PostPosted: Sat Apr 23, 2005 7:53 am     Reply with quote

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

View user's profile Send private message

Use the link below
PostPosted: Sat Apr 23, 2005 8:14 am     Reply with quote

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

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

Routine for RS232
PostPosted: Wed Apr 27, 2005 8:20 pm     Reply with quote

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"
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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