avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Data Array alignment


From: Dmitry K.
Subject: Re: [avr-gcc-list] Data Array alignment
Date: Tue, 6 Jun 2006 08:35:42 +1100
User-agent: KMail/1.5

On Monday 05 June 2006 10:42, Trampas wrote:
> Ok, I know somewhere there is a manual where this information exists, but I
> have not found it.
>
> I am using a buffer in an ISR
>
> #define BUFF_SIZE 0x1F
> UINT8 Data[BUFF_SIZE];
> volatile UINT8 Read;
> volatile UINT8 Write;
>
> ISR(xxx)
> {
>       //OK to over write if not read in time
>       Data[Write++]=mydata;
>       Write=Write & BUFF_SIZE;
> }
>
> Void Data_Sink()
> {
>       If (Read!=Write)
>       {
>               Mydata=Data[Read++];
>               Read=Read & BUFF_SIZE;
>       }
> }
>
> I was wondering if someone had a clever way of speeding this up, by maybe
> aligning the data buffer in memory and using pointers?

A simple improvement: delete 'volatile' where not
needed, for example (-4 clocks):

   ISR(xxx)
   {
        unsigned char i = Write;
        Data[i++]=mydata;
        Write= i & BUFF_SIZE;
   }

Regards,
Dmitry.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]