Content originally posted in LPCWare by kizerkid on Mon Oct 17 23:47:03 MST 2011
For my int. latency test, I've used 'extint' example from 'LPCXpresso Example Projects for LPC1114/302 V2.0' as based project on 'LPCXpresso v4.1.0' suite. The overall code is shown below:
Quote:
=====Main===========
int main (void)
{
GPIOInit();/* Initialize GPIO (sets up clock) */
/* use port2_1 as input event, interrupt test. */
LPC_IOCON->PIO2_1 |= 0x08;//pull-down input
GPIOSetDir( PORT2, 1, 0 );
GPIOSetInterrupt( PORT2, 1, 0, 1, 0 );//both edge trig
GPIOIntEnable( PORT2, 1 );
/* Set LED port line to output (Port0.7)*/
GPIOSetDir( LED_PORT, LED_BIT, 1 );
GPIOSetValue( LED_PORT, LED_BIT, LED_OFF );
while( 1 );
}
=====INT.=======
asm (".equ GPIO0_7DAT, 0x50000200");
asm (".equ GPIO2_IC, 0x5002801C");
void PIOINT2_IRQHandler(void)
{
asm(
"ldr r1,=GPIO0_7DAT;"
"mov r2,#128;"
"str r2,[r1];" //ON LED(P0.7)
"mov r2,#0;"
"str r2,[r1];" //OFF LED(P0.7)
//clear INT.
"ldr r1,=GPIO2_IC;"
"mov r0,#2;"
"str r0,[r1];"
);
return;
}
Actually, my 1.6usec job can be done well with assembly language on ATTINY2313(8bit), but I must overclock it from 20MHz to 25MHz. Thus, I try to find new MCU that can done the task without overclock. After I found LPC Cortex M0, I think this MCU is matched! because of 50MHz operation with almost 1 clock cycle instruction. However, it's quite surprise for me that it can't be done..because of:
1. Interrupt latency
2. Less register
3. Less 1clk instruction and 3clk for branch
Anyway, I think I can do my job with new program that not use interrupt (using polling instead), however I still wish that I can use the interrupt..if I can reduce its response time to about 0.4usec (~20clk)
Thank you :)