void TIMER16_0_IRQHandler(void) { if (Chip_TIMER_CapturePending( LPC_TIMER16_0, 0 )) { //capture interrupt? LPC_TIMER16_0->TC = 0; //reset timer period = Chip_TIMER_ReadCapture( LPC_TIMER16_0, 0 ); //save counter CR0 Chip_TIMER_ClearCapture( LPC_TIMER16_0, 0 ); //reset capture interrupt } } // // setup timer16_0 with counting milliseconds // generate interrupt on falling edge at PIO0_2 // Chip_TIMER_Init(LPC_TIMER16_0); // enable clock timer16_0 Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 2, // CT16B0_CAP0 & pullup (pio2_2) (IOCON_FUNC2 | IOCON_MODE_PULLUP) ); Chip_TIMER_TIMER_SetCountClockSrc( LPC_TIMER16_0, // use timer mode TIMER_CAPSRC_RISING_PCLK, 0 ); Chip_TIMER_CaptureFallingEdgeEnable( LPC_TIMER16_0, 0 ); // set falling edge Chip_TIMER_CaptureEnableInt( LPC_TIMER16_0, 0 ); // set interrupt for pio0_2 Chip_TIMER_PrescaleSet( LPC_TIMER16_0, 47999 ); // prescaler 48000, milliseconds Chip_TIMER_Enable(LPC_TIMER16_0); // enable timer start counting NVIC_ClearPendingIRQ(TIMER_16_0_IRQn); NVIC_EnableIRQ(TIMER_16_0_IRQn); //enable interrupt |