LPC1114 Timer Capture use with Chip Library functions

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1114 Timer Capture use with Chip Library functions

889 Views
lpcware
NXP Employee
NXP Employee
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

Labels (1)
0 Kudos
Reply
2 Replies

711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Mar 09 09:44:37 MST 2015

Quote: jschimpf255

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);




Changing the pin function to disable capture  :D  :D 
0 Kudos
Reply

712 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nerd herd on Mon Mar 09 09:09:01 MST 2015
Hi jschimpf255,

Thank you for contributing to the LPCWare community!
0 Kudos
Reply