I'm working with ATMEGA64 microcontroller which issues AT commands to
a bluetooth module.The bluetooth module communicates with mobile
phones and it returns the results back to the microcontroller.
So, I have no clear understanding about how to store the received data
in the microcontroller.Becuase several phones can reply for the same
inquiry message with small time gaps.
thanks in advance.
regards,
Raneetha.

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
On Tue, Mar 11, 2008 at 01:29:05PM -0000, raneethavasundara wrote:
> I'm working with ATMEGA64 microcontroller which issues AT commands to
> a bluetooth module.The bluetooth module communicates with mobile
> phones and it returns the results back to the microcontroller.
>
> So, I have no clear understanding about how to store the received data
> in the microcontroller.Becuase several phones can reply for the same
> inquiry message with small time gaps.
You do not have a UART problem, you have a problem in not knowing how to
write or structure your application.
I suggest you start by coding one of the timers to interrupt 50, 60,
or 100 times per second. Some number of times thats handy for you to
measure time. Then I suggest you multiplex off that timer creating
"software timers" something like this:
volatile uint8_t phone_ticks, led_ticks, switch_ticks;
ISR(the_timer_vector)
{
if( phone_ticks ) // don't decrement if its already zero
phone_ticks--;
if( led_ticks )
led_ticks--;
if( switch_ticks )
switch_ticks--;
}
Then if your tick interrupt rate is 100 you can say "phone_ticks =
100;" in your main loop, go do other things and periodically look to
see if phone_ticks has reached zero. When it reaches zero you know it
was last set a second ago. You want something like this to know when
the last time you sent commands to the phone(s) that you don't flood
them with commands.
Do the same thing when waiting for an answer. If the phone doesn't
respond in a reasonable time then do something to recover from the
situation.
I think you want to allocate a receive buffer for incoming characters
from the phone and service this in an interrupt. You need an index for
the latest character from the phones, and another index indicating the
next character to be removed. If these two indexes have the same value
then your buffer is empty. Standard FIFO software buffer.
Creating event loops to parse incoming serial sentences is also
standard embedded fare. When your timers and serial handlers are
running in interrupt space you can dedicate your foreground CPU time
to processing of the data. Don't try to parse the serial sentences in
your receive interrupt routine.
--
David Kelly N4HHE, d...@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )