![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Guest
|
UART message capture |
Posted: Tue Dec 14, 2004 7:59 pm |
|
|
Hi all,
I am using the PIC18LF452 in a project, and it's UART to talk to a 433Mhz transceiver. It needs an "AT" command, and sends back a "\r\nOK\r\n".
From what i've read in the manual, it uses a much stripped down version of the AT Hayes command set, that is used in modems.
What i want to do is read in the response, and process it to get any data other than the OK. I think i should use the interrupt RDA, and i have seen code to do that in the examples.
Sometimes a response has more than 2 pairs of "\r\n". A pair for the data, and a pair for the OK.
I need to know:
>Should i use a circular buffer, or linear? and why?
>How do i get the whole response? given that i can't rely on the "\r\n" to indicate the response, without losing the data OR "OK" to validate.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Dec 14, 2004 10:07 pm |
|
|
Hi Mark,
Thanks for the reply, i think a linear buffer should do the trick for now, i'll just make it long enough for big data bursts.
Should i wait for the 1st "\r\n" and disable the interrupt, and use fetc() until no more chars are read in? because i'll get something like "\r\nddddddddddddddd\r\nddddddddddddd\r\nOK\r\n". I don't have a particular 'start' or 'end' character to reference to.
What i mean is something like:
Code: |
#int_RDA
RDA_isr()
{
buffer[next_in] = getc() //read the uarts 1st buffer char
increment next_in
buffer[next_in]= getc(); // read the uarts 2nd buffer char
if (buffer[next_in-1]==13)&(buffer[next_in]==10))
{
found start (possibly)
disable_interrupt(int_RDA);
do
{ // do this quickly enough to avoid RS232 errors (OERR, FERR)
buffer[next_in] = getc()
increment next_in
}while (kbhit() )
enable_interrupt(int_RDA);
//when kbhit fails= no data in RCREG, return to normal operation
//should have a buffer with data to parse
}
}
|
I am only using the interrupt to gather the data so i can process it later in the program.
After it is processed, i then flush the buffer elements to theNull char '0' ready to be used again.
Q's
==
>Would this be adequate? or do i have other things to check?
>After gathering the input data, should i turn off the interrupt so that the buffer isn't corrupted during processing, and re-enable for non process activities so that i can response to incomming radio messages?
Thanks so far. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|