Max GPIO Frequency LPC11C24

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Max GPIO Frequency LPC11C24

1,234 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Caradhras on Sun Jul 15 13:04:34 MST 2012
Hi,

I just did some tests with my logic analyzer to measure the maximum Speed at which the LPC11C24 can toggle a pin.

In the main loop i got just this statement (no interrupts active):
while(1)
{
LPC_GPIO0->MASKED_ACCESS[(1<<2)] ^= (1<<2); // PIO0_2
}


I switched on the clock in SYSAHB, set the direction and so on. In the optimization settings I chose Optimize most -O3.

With these settings I got a maximum toggling frequency of 2 MHz as long as my 70 EUR and 20 MHz logic analyzer is correct...:rolleyes:

Is that a realistc value? Is it the maximum speed I can expect from the mcu? Maybe I forgot to set a parameter and it can do it much faster? Some forums on the interweb told me puny atmels at 16MHz can do more ^^
0 Kudos
Reply
4 Replies

1,174 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elef on Mon Jul 16 19:49:57 MST 2012
The hardware is capable of toggling using a single 2 cycle instruction.
Given that your LPC11C24 runs at 50MHz Max, the fastest toggling you can get on your GPIO is 25MHz. Because your logic analyser is 20Mhz max and you can't measure 25Mhz, i suggest try run your CPU at say 12Mhz, and you should see your GPIO speed at 6MHz.

But as kayoda said, don't waste your cycles on branching through a while(1) loop.
0 Kudos
Reply

1,174 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Caradhras on Sun Jul 15 23:54:40 MST 2012
Ah, that thread is exactly what i was looking for. Didnt find it with the searchfunction...:(
It wantedt to know what speeds can be done with stupid software interfaces...

Thanks! :)
0 Kudos
Reply

1,174 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Sun Jul 15 18:16:35 MST 2012
Don't understand the sense of this :confused:, but anyway:

Your code is wasting time with reading and branching :mad: Try a smart versions like:
while(1)
{
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] = (1<<2); // PIO0_2
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] =~(1<<2); // PIO0_2
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] = (1<<2); // PIO0_2
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] =~(1<<2); // PIO0_2
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] = (1<<2); // PIO0_2
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] =~(1<<2); // PIO0_2
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] = (1<<2); // PIO0_2
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] =~(1<<2); // PIO0_2
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] = (1<<2); // PIO0_2
    LPC_GPIO0->MASKED_ACCESS[(1<<2)] =~(1<<2); // PIO0_2
}
and you can read the real switching frequency: 12MHz :eek:

Note: This is the showed scope frequency (=complete ON/OFF cycle) at 48MHz. A single ON/OFF time is therefore 1/24MHz = 2 cycles (without loop branching).

See also: http://knowledgebase.nxp.com/showthread.php?t=1832
0 Kudos
Reply

1,174 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micrio on Sun Jul 15 13:55:50 MST 2012
Have a look at the assembly code.   Your code is reading the I/O port then
writing it.   It is also doing a "not" operation.  

Your code may not be aligned.   This can cause a cache miss.   Running
out of flash adds wait states.   

You could run out of RAM which has no wait states but is a little
more tricky to program.  

To get the absolute fastest code you will probably have to write some
of it in assembly.


Pete.
0 Kudos
Reply