lpcware

LPC1114 Timer Capture use with Chip Library functions

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by jschimpf255 on Mon Mar 09 09:00:18 MST 2015
Hi,
  I was wanting to use the capture registers on the LPC1114 timers.  While there were many examples none seemed to use the Chip library that comes with lpcopen_v2_00a_lpcxpresso_nxp_lpcxpresso_11c24 set of examples and code. To rectify that here is a simple example to set up CAP0 for the the 16 bit timer 0 written using these functions.

Chip_TIMER_Init(LPC_TIMER16_0);

// LPC114 Manual Page 75 ICON_PIO0_2 register 0x4004 401C)
// 0x10 => Turn pullup
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_2, IOCON_FUNC2 | 0x10);

Chip_TIMER_CaptureFallingEdgeEnable(LPC_TIMER16_0,0);// Falling edge
Chip_TIMER_CaptureEnableInt(LPC_TIMER16_0,0);// Enable INT
Chip_TIMER_Enable(LPC_TIMER16_0);                                                              // Start timer
NVIC_EnableIRQ(TIMER_16_0_IRQn);// Turn on int

Right after this step the capture is armed and will in this case generate an interrupt calling:

void TIMER16_0_IRQHandler(void)
{
// Clear the capture interrupt

Chip_TIMER_ClearCapture(LPC_TIMER16_0,0);   // You have to do this
               :
               :
  Any other interrupt actions.

If you want to disable the capture temporally you just:

// Disable the INPUTS with the MUX
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_2, IOCON_FUNC0 | 0x10);

To re-enable

// Turn on the inputs with the MUX
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_2, IOCON_FUNC2 | 0x10);

You can see the Chip timer library for many more functions for setting edge conditions, match interrupts and other timer related functions.

--jim schimpf

Outcomes