Optimization of Capture Routine
2004-01-31 by capiman@t-online.de
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++;
; }
}
{
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
ldr ip, [r0, #0]
strb ip, [r2], #1
cmp r2, r1
bcc .L142
Are there any other tricks ?
Environment: LPC2106, with 14,745 MHz, M = 4, P =
2, VPBDIV = 1, MAMTIM = 3 (same with not allowed value 2), MAMCR = 1 or
2
I tried overclocking with M = 5 (should give me
around 75 MHz), but even there speed doesn't increase anymore ???
UART speed was changed, but not CPU
speed.
BTW: Is the time distance between the measured
bytes always the same ? Or are e.g. odd addresses slower then even addresses
?
Greetings,
Martin