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

How #RDA_int works? vs kbhit() ?

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



Joined: 21 Dec 2004
Posts: 45

View user's profile Send private message

How #RDA_int works? vs kbhit() ?
PostPosted: Wed Jun 29, 2005 10:02 pm     Reply with quote

Hi

Im interesed in to know how #rda_int works---

1.- How many bytes arrives to activate the interrupt?
2.- Does the interrupt returns to the previous state of program after receive a char on usart?


3.- If my modem echoes the AT commands sent to it, i should be disable the rda_int wainting finish the command?.

4.- what diference exist between rda_int versus kbhit for this purpose?

Thank you very much

Bye
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Thu Jun 30, 2005 1:07 am     Reply with quote

densimitre wrote:

1.- How many bytes arrives to activate the interrupt?

1 byte is enough to fire the ISR.

densimitre wrote:

2.- Does the interrupt returns to the previous state of program after receive a char on usart?

Yes.

densimitre wrote:

4.- what diference exist between rda_int versus kbhit for this purpose?

kbhit() is for polling the buffer. You can use kbhit() like this

Code:

int8 i = 0, c = 0x00;

while (i < TIMEOUT)
{
   if (kbhit())  // check if there is a character
   {
      c = getc(); // waits until the character arrives.  it can wait FOREVER.
      break;
   }
   delay_us(10);  // delay depends on you data rate
   ++i;
}

if (i == TIMEOUT)
{
   // handle timeout
}



#int_rda is a declaration of the ISR.
densimitre



Joined: 21 Dec 2004
Posts: 45

View user's profile Send private message

PostPosted: Thu Jun 30, 2005 11:18 am     Reply with quote

Thank you

Then, if a want receive a string like "<CR><LF>OK<CR><LF>", the rda_int drives each character individually and exit the isr routine, to receive next charecter again?

Example:

Code:
printf("AT\r");


the modem echoes the AT (tested using hyperterminal), then rda_int fires for A char and T char? one after one?..or fires once for entire string?

Sorry for the questions, but i am a lit confused...

Bye
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Thu Jun 30, 2005 12:27 pm     Reply with quote

#INT_RDA should be used only if the involved microcontroller has
the internal built-in hardware USART.

kbhit() is used widely to implement a software USART only to detect the START bit.
Using hardware USART, kbhit() return TRUE if a character has been received and is
waiting to be read in the hardware buffer.

A software USART can be enhanced if it's combined with #INT_EXT and
int_ext_edge(H_TO_L) function to get an interrupt when receiving
a char in RS232.

Then inside the #INT_RDA or #INT_EXT isr you can use the function getc()
to get the incoming character.


kbhit() 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.


Keep well,

Humberto
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