For what it's worth, here's the assembly generated for your loop (with my comments):
LDR R0, =0x40028000 ; R0 = LPC_GPIOINT_BASE
LDR R2, =0x2009C000 ; R2 = LPC_GPIO_BASE
MOVS R1, #0x20
loop_wait
LDR.W R3, [R0,#0x80] ; R3 = IntStatus (0x40028080)
CMP R3, #0 ; R3 = 0?
BEQ loop_wait ; if yes, continue looping
STR R1, [R2,#0x58] ; FIO2SET (0x2009C058) = 0x20
LDR.W R3, [R0,#0x84] ; R3 = IO0IntStatR (0x40028084)
TST.W R3, #0x1000000 ; R3 & (1<<24)
BEQ loop_wait ; if 0, continue looping
LDR.W R3, [R0,#0x8C] ; R3 = IO0IntClr (0x4002808C)
ORR.W R3, R3, #0x1000000 ; R3 |= 1<<24
STR.W R3, [R0,#0x8C] ; IO0IntClr (0x4002808C) = R3
STR R1, [R2,#0x5C] ; FIO2CLR (0x2009C05C) = 0x20
B loop_wait
Hi,
I want to be able to measure very short delays, in the range,say, from 50 nsecs to 5 microsecs.
To start, with I used GPIO as interrupts - as in the following code with an external pulse source connected to p16.
while(1){
while(LPC_GPIOINT->IntStatus==0);
LPC_GPIO2->FIOSET = TEST_1;
if(LPC_GPIOINT->IO0IntStatR & (1 << 24)) {
// LPC_GPIO2->FIOSET = TEST_1;
LPC_GPIOINT->IO0IntClr |= (1<<24);
LPC_GPIO2->FIOCLR = TEST_1;
}
The delay in reaching the first FIOSET from the rising edge of the input pulse is around 260 ns, from this line to the second FIOSET is another 260 ns and another 580 ns until the FIOCLR line completes. Running back-to-back FIOSET/FIOCLR shows about 10 nsecs so the device certainly runs fast enough.
These times are much slower than I expected so I guess I should really be using the external interrupt pins EINT0- EINT3 but these don't seem to accessible on the mbed?
EINT1 and EINT2 don't seem to be connected anywhere in the mbed schematic. Is this correct? Maybe I could attach a fine wire???
Thanks for any help.
John.