You could use the capture feature of the timers. I have used this to measure time delays of a few nanoseconds of two separate signals at a 1 MHz repetition rate using two inputs thus:
void TIMER0_IRQHandler (void)
{
clear interrupt flag for capture channel 0 event.
if ( LPC_TIM0->IR & (0x1<<4) )
{
LPC_TIM0->IR = 0x1<<4; /* clear interrupt flag */
LPC_GPIO0->FIOSET = (1<<CH0);
}
clear interrupt flag for capture channel 1 event.
if ( LPC_TIM0->IR & (0x1<<5) )
{
LPC_TIM0->IR = 0x1<<5; /* clear interrupt flag */
LPC_GPIO0->FIOCLR = (1<<CH0);
time0 = LPC_TIM0->CR0;
time1 = LPC_TIM0->CR1;
diff_time = time1 - time0;
...............................
}
In your case there is only one signal, so you could still direct it to two capture inputs, one of which is set to fire on the rising edge, the other on the falling.
JohnR
I am measuring a square wave signal (0-5V) with a minimum pulse width of 1usec and minimum duty cycle of 10% low. I would like to measure the sum of the low pulse widths over a fixed time period, such as 1 sec, and output that to serial. I tried to use the method described in this forum post: http://mbed.org/forum/mbed/topic/2326/ but it's not working for me. I'm new to embedded programming so just learning about interrupts and ISRs.
Thanks, Anna
/media/uploads/miriya52/mbed_code.pdf