Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2100] Optimization of Capture Routine

2004-02-01 by Ben Dooks

On Sat, Jan 31, 2004 at 09:01:05PM +0100, capiman@... wrote:
> Hello,
> 
> i want to read in 1 byte multiple times from the port pins as fast as possible:
> Currently i have the following C code:
> 
> unsigned char Data[60000];
> 
> void CaptureBuffer()
> {
>     unsigned char *ptr = &Data[0];
>     unsigned char *ptrend = &Data[60000];
>     
>     while(ptr < ptrend)
>     {
>         (*ptr) = (IOPIN >> LA_D0_BIT) & 0xff;
>         ptr++;
>     }
> }
> 
> When i compile it with gcc and option -O3, i can capture with around 3,9 MBytes/sec.
> Avoiding the shift (by using P0.0 - P0.7) gives me 4,2 MBytes/sec. 
> Leaving out the (*ptr) = (IOPIN...) instruction gives me 11,8 MBytes/sec, but no more functionality :-)
> 
> Can i improve the speed with inline assembler ? Produced assembler code already looks very compact...
> 
> .L142:
>  ldr ip, [r0, #0]
>  strb ip, [r2], #1
>  cmp r2, r1
>  bcc .L142
> 
> Are there any other tricks ?

unrolling the loop a bit may help, as it reduces the number of branch
instructions needed.

-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.