Reply by raj November 16, 20092009-11-16
Pls send me timer code for mega AVR device. It should run all timer.

rgds,
raj
On Thu, 12 Nov 2009 23:54:02 +0530 wrote
>

Hi,

On Thu, Nov 12, 2009 at 3:34 AM, Muhammad Yasir wrote:
> I want to do GPS data logging on a serial memory 24C512
>
> Could somebody please email the c-code for real time circular buffer
>
> Data needs to be continuously copied to the buffer while data bytes
> are retrieved from the
> buffer only at will or on demand

I found a really nice set of circular buffer routines from an embedded
newletter (The Embedded Muse)
I've packaged them up into a header file, which you can find over here:
It can be used as a set of C macros, or as a C++ template.

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/



Reply by Dave Hylands November 12, 20092009-11-12
Hi,

On Thu, Nov 12, 2009 at 3:34 AM, Muhammad Yasir wrote:
> I want to do GPS data logging on a serial memory 24C512
>
> Could somebody please email the c-code for real time circular buffer
>
> Data needs to be continuously copied to the buffer while data bytes
> are retrieved from the
> buffer only at will or on demand

I found a really nice set of circular buffer routines from an embedded
newletter (The Embedded Muse)


I've packaged them up into a header file, which you can find over here:


It can be used as a set of C macros, or as a C++ template.

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/
Reply by David Kelly November 12, 20092009-11-12
On Thu, Nov 12, 2009 at 04:34:52PM +0500, Muhammad Yasir wrote:
> I want to do GPS data logging on a serial memory 24C512
>
> Could somebody please email the c-code for real time circular buffer

A circular buffer is a very very basic thing, only one step up from
"Hello, World!\n".

#define BUFFER_SIZE 64
uint8_t buffer[BUFFER_SIZE];
uint8_t buffer_head = 0, buffer_tail = 0;

void put_in_buffer( uint8_t data )
{
buffer[buffer_head] = data;
if( ++buffer_head >= BUFFER_SIZE )
buffer_head = 0;
}

uint8_t available_buffer( void )
{
// This is the hardest part,
// calculating the size of data in buffer.
return( (buffer_head - buffer_tail ) % BUFFER_SIZE );
}

uint8_t get_from_buffer( void )
{
uint8_t data;

data = buffer[buffer_tail];
if( ++buffer_tail >= BUFFER_SIZE )
buffer_tail = 0;

return data;
}

main()
{
uint8_t c;

put_in_buffer( 10 );

// don't read from buffer unless it has data
if( available_in_buffer() )
c = get_from_buffer();
}

> Data needs to be continuously copied to the buffer while data bytes
> are retrieved from the buffer only at will or on demand

You are going to have to do something for yourself. The basics are
demonstrated above. You have to expand it to apply to your serial
memory.

--
David Kelly N4HHE, d...@HiWAAY.net
=======================================================================Whom computers would destroy, they must first drive mad.
Reply by Muhammad Yasir November 12, 20092009-11-12
I want to do GPS data logging on a serial memory 24C512

Could somebody please email the c-code for real time circular buffer

Data needs to be continuously copied to the buffer while data bytes
are retrieved from the
buffer only at will or on demand

regards
m.yasir