Date: March 20, 2011 This library is created from "LPC17xx CMSIS-Compliant Standard Peripheral Firmware Driver Library (GNU, Keil, IAR) (Jan 28, 2011)", available from NXP's website, under "All microcontrollers support documents" [[http://ics.nxp.com/support/documents/microcontrollers/?type=software]] You will need to follow [[/projects/libraries/svn/mbed/trunk/LPC1768/LPC17xx.h]] while using this library Examples provided here [[/users/frank26080115/programs/LPC1700CMSIS_Examples/]] The beautiful thing is that NXP does not place copyright protection on any of the files in here Only a few modifications are made to make it compile with the mbed online compiler, I fixed some warnings as well. This is untested as of March 20, 2011 Forum post about this library: [[/forum/mbed/topic/2030/]]

Embed: (wiki syntax)

« Back to documentation index

TIM Public Functions

TIM Public Functions
[TIM]

Functions

FlagStatus TIM_GetIntStatus (LPC_TIM_TypeDef *TIMx, TIM_INT_TYPE IntFlag)
 Get Interrupt Status.
FlagStatus TIM_GetIntCaptureStatus (LPC_TIM_TypeDef *TIMx, TIM_INT_TYPE IntFlag)
 Get Capture Interrupt Status.
void TIM_ClearIntPending (LPC_TIM_TypeDef *TIMx, TIM_INT_TYPE IntFlag)
 Clear Interrupt pending.
void TIM_ClearIntCapturePending (LPC_TIM_TypeDef *TIMx, TIM_INT_TYPE IntFlag)
 Clear Capture Interrupt pending.
void TIM_ConfigStructInit (TIM_MODE_OPT TimerCounterMode, void *TIM_ConfigStruct)
 Configuration for Timer at initial time.
void TIM_Init (LPC_TIM_TypeDef *TIMx, TIM_MODE_OPT TimerCounterMode, void *TIM_ConfigStruct)
 Initial Timer/Counter device Set Clock frequency for Timer Set initial configuration for Timer.
void TIM_DeInit (LPC_TIM_TypeDef *TIMx)
 Close Timer/Counter device.
void TIM_Cmd (LPC_TIM_TypeDef *TIMx, FunctionalState NewState)
 Start/Stop Timer/Counter device.
void TIM_ResetCounter (LPC_TIM_TypeDef *TIMx)
 Reset Timer/Counter device, Make TC and PC are synchronously reset on the next positive edge of PCLK.
void TIM_ConfigMatch (LPC_TIM_TypeDef *TIMx, TIM_MATCHCFG_Type *TIM_MatchConfigStruct)
 Configuration for Match register.
void TIM_UpdateMatchValue (LPC_TIM_TypeDef *TIMx, uint8_t MatchChannel, uint32_t MatchValue)
 Update Match value.
void TIM_ConfigCapture (LPC_TIM_TypeDef *TIMx, TIM_CAPTURECFG_Type *TIM_CaptureConfigStruct)
 Configuration for Capture register.
uint32_t TIM_GetCaptureValue (LPC_TIM_TypeDef *TIMx, TIM_COUNTER_INPUT_OPT CaptureChannel)
 Read value of capture register in timer/counter device.

Function Documentation

void TIM_ClearIntCapturePending ( LPC_TIM_TypeDef *  TIMx,
TIM_INT_TYPE  IntFlag 
)

Clear Capture Interrupt pending.

Parameters:
[in]TIMxTimer selection, should be

  • LPC_TIM0: TIMER0 peripheral
    • LPC_TIM1: TIMER1 peripheral
    • LPC_TIM2: TIMER2 peripheral
    • LPC_TIM3: TIMER3 peripheral
[in]IntFlaginterrupt type, should be:

  • TIM_MR0_INT: Interrupt for Match channel 0
    • TIM_MR1_INT: Interrupt for Match channel 1
    • TIM_MR2_INT: Interrupt for Match channel 2
    • TIM_MR3_INT: Interrupt for Match channel 3
    • TIM_CR0_INT: Interrupt for Capture channel 0
    • TIM_CR1_INT: Interrupt for Capture channel 1
Returns:
None

Definition at line 235 of file lpc17xx_timer.c.

void TIM_ClearIntPending ( LPC_TIM_TypeDef *  TIMx,
TIM_INT_TYPE  IntFlag 
)

Clear Interrupt pending.

Parameters:
[in]TIMxTimer selection, should be:

  • LPC_TIM0: TIMER0 peripheral
    • LPC_TIM1: TIMER1 peripheral
    • LPC_TIM2: TIMER2 peripheral
    • LPC_TIM3: TIMER3 peripheral
[in]IntFlag,:interrupt type, should be:

  • TIM_MR0_INT: Interrupt for Match channel 0
  • TIM_MR1_INT: Interrupt for Match channel 1
  • TIM_MR2_INT: Interrupt for Match channel 2
  • TIM_MR3_INT: Interrupt for Match channel 3
  • TIM_CR0_INT: Interrupt for Capture channel 0
  • TIM_CR1_INT: Interrupt for Capture channel 1
Returns:
None

Definition at line 212 of file lpc17xx_timer.c.

void TIM_Cmd ( LPC_TIM_TypeDef *  TIMx,
FunctionalState  NewState 
)

Start/Stop Timer/Counter device.

Parameters:
[in]TIMxPointer to timer device, should be:

  • LPC_TIM0: TIMER0 peripheral
    • LPC_TIM1: TIMER1 peripheral
    • LPC_TIM2: TIMER2 peripheral
    • LPC_TIM3: TIMER3 peripheral
[in]NewState
  • ENABLE : set timer enable
  • DISABLE : disable timer
Returns:
None

Definition at line 396 of file lpc17xx_timer.c.

void TIM_ConfigCapture ( LPC_TIM_TypeDef *  TIMx,
TIM_CAPTURECFG_Type TIM_CaptureConfigStruct 
)

Configuration for Capture register.

Parameters:
[in]TIMxPointer to timer device, should be:

  • LPC_TIM0: TIMER0 peripheral
    • LPC_TIM1: TIMER1 peripheral
    • LPC_TIM2: TIMER2 peripheral
    • LPC_TIM3: TIMER3 peripheral
      • CaptureChannel: set the channel to capture data
      • RisingEdge : if SET, Capture at rising edge
      • FallingEdge : if SET, Capture at falling edge
      • IntOnCaption : if SET, Capture generate interrupt
[in]TIM_CaptureConfigStructPointer to TIM_CAPTURECFG_Type
Returns:
None

Definition at line 542 of file lpc17xx_timer.c.

void TIM_ConfigMatch ( LPC_TIM_TypeDef *  TIMx,
TIM_MATCHCFG_Type TIM_MatchConfigStruct 
)

Configuration for Match register.

Parameters:
[in]TIMxPointer to timer device, should be:

  • LPC_TIM0: TIMER0 peripheral
    • LPC_TIM1: TIMER1 peripheral
    • LPC_TIM2: TIMER2 peripheral
    • LPC_TIM3: TIMER3 peripheral
[in]TIM_MatchConfigStructPointer to TIM_MATCHCFG_Type

  • MatchChannel : choose channel 0 or 1
  • IntOnMatch : if SET, interrupt will be generated when MRxx match the value in TC
  • StopOnMatch : if SET, TC and PC will be stopped whenM Rxx match the value in TC
  • ResetOnMatch : if SET, Reset on MR0 when MRxx match the value in TC -ExtMatchOutputType: Select output for external match + 0: Do nothing for external output pin if match + 1: Force external output pin to low if match + 2: Force external output pin to high if match + 3: Toggle external output pin if match MatchValue: Set the value to be compared with TC value
Returns:
None

Definition at line 450 of file lpc17xx_timer.c.

void TIM_ConfigStructInit ( TIM_MODE_OPT  TimerCounterMode,
void *  TIM_ConfigStruct 
)

Configuration for Timer at initial time.

Parameters:
[in]TimerCounterModetimer counter mode, should be:

  • TIM_TIMER_MODE: Timer mode
  • TIM_COUNTER_RISING_MODE: Counter rising mode
  • TIM_COUNTER_FALLING_MODE: Counter falling mode
  • TIM_COUNTER_ANY_MODE:Counter on both edges
[in]TIM_ConfigStructpointer to TIM_TIMERCFG_Type or TIM_COUNTERCFG_Type
Returns:
None

Definition at line 253 of file lpc17xx_timer.c.

void TIM_DeInit ( LPC_TIM_TypeDef *  TIMx )

Close Timer/Counter device.

Parameters:
[in]TIMxPointer to timer device, should be:

  • LPC_TIM0: TIMER0 peripheral
  • LPC_TIM1: TIMER1 peripheral
  • LPC_TIM2: TIMER2 peripheral
  • LPC_TIM3: TIMER3 peripheral
Returns:
None

Definition at line 363 of file lpc17xx_timer.c.

uint32_t TIM_GetCaptureValue ( LPC_TIM_TypeDef *  TIMx,
TIM_COUNTER_INPUT_OPT  CaptureChannel 
)

Read value of capture register in timer/counter device.

Parameters:
[in]TIMxPointer to timer/counter device, should be:

  • LPC_TIM0: TIMER0 peripheral
    • LPC_TIM1: TIMER1 peripheral
    • LPC_TIM2: TIMER2 peripheral
    • LPC_TIM3: TIMER3 peripheral
[in]CaptureChannel,:capture channel number, should be:

  • TIM_COUNTER_INCAP0: CAPn.0 input pin for TIMERn
  • TIM_COUNTER_INCAP1: CAPn.1 input pin for TIMERn
Returns:
Value of capture register

Definition at line 570 of file lpc17xx_timer.c.

FlagStatus TIM_GetIntCaptureStatus ( LPC_TIM_TypeDef *  TIMx,
TIM_INT_TYPE  IntFlag 
)

Get Capture Interrupt Status.

Parameters:
[in]TIMxTimer selection, should be:

  • LPC_TIM0: TIMER0 peripheral
  • LPC_TIM1: TIMER1 peripheral
  • LPC_TIM2: TIMER2 peripheral
  • LPC_TIM3: TIMER3 peripheral
[in]IntFlag,:interrupt type, should be:

  • TIM_MR0_INT: Interrupt for Match channel 0
  • TIM_MR1_INT: Interrupt for Match channel 1
  • TIM_MR2_INT: Interrupt for Match channel 2
  • TIM_MR3_INT: Interrupt for Match channel 3
  • TIM_CR0_INT: Interrupt for Capture channel 0
  • TIM_CR1_INT: Interrupt for Capture channel 1
Returns:
FlagStatus
  • SET : interrupt
  • RESET : no interrupt

Definition at line 186 of file lpc17xx_timer.c.

FlagStatus TIM_GetIntStatus ( LPC_TIM_TypeDef *  TIMx,
TIM_INT_TYPE  IntFlag 
)

Get Interrupt Status.

Parameters:
[in]TIMxTimer selection, should be:

  • LPC_TIM0: TIMER0 peripheral
    • LPC_TIM1: TIMER1 peripheral
    • LPC_TIM2: TIMER2 peripheral
    • LPC_TIM3: TIMER3 peripheral
[in]IntFlag,:interrupt type, should be:

  • TIM_MR0_INT: Interrupt for Match channel 0
  • TIM_MR1_INT: Interrupt for Match channel 1
  • TIM_MR2_INT: Interrupt for Match channel 2
  • TIM_MR3_INT: Interrupt for Match channel 3
  • TIM_CR0_INT: Interrupt for Capture channel 0
  • TIM_CR1_INT: Interrupt for Capture channel 1
Returns:
FlagStatus
  • SET : interrupt
  • RESET : no interrupt

Definition at line 156 of file lpc17xx_timer.c.

void TIM_Init ( LPC_TIM_TypeDef *  TIMx,
TIM_MODE_OPT  TimerCounterMode,
void *  TIM_ConfigStruct 
)

Initial Timer/Counter device Set Clock frequency for Timer Set initial configuration for Timer.

Parameters:
[in]TIMxTimer selection, should be:

  • LPC_TIM0: TIMER0 peripheral
  • LPC_TIM1: TIMER1 peripheral
  • LPC_TIM2: TIMER2 peripheral
  • LPC_TIM3: TIMER3 peripheral
[in]TimerCounterModeTimer counter mode, should be:

  • TIM_TIMER_MODE: Timer mode
  • TIM_COUNTER_RISING_MODE: Counter rising mode
  • TIM_COUNTER_FALLING_MODE: Counter falling mode
  • TIM_COUNTER_ANY_MODE:Counter on both edges
[in]TIM_ConfigStructpointer to TIM_TIMERCFG_Type that contains the configuration information for the specified Timer peripheral.
Returns:
None

Definition at line 287 of file lpc17xx_timer.c.

void TIM_ResetCounter ( LPC_TIM_TypeDef *  TIMx )

Reset Timer/Counter device, Make TC and PC are synchronously reset on the next positive edge of PCLK.

Parameters:
[in]TIMxPointer to timer device, should be:

  • LPC_TIM0: TIMER0 peripheral
    • LPC_TIM1: TIMER1 peripheral
    • LPC_TIM2: TIMER2 peripheral
    • LPC_TIM3: TIMER3 peripheral
Returns:
None

Definition at line 420 of file lpc17xx_timer.c.

void TIM_UpdateMatchValue ( LPC_TIM_TypeDef *  TIMx,
uint8_t  MatchChannel,
uint32_t  MatchValue 
)

Update Match value.

Parameters:
[in]TIMxPointer to timer device, should be:

  • LPC_TIM0: TIMER0 peripheral
    • LPC_TIM1: TIMER1 peripheral
    • LPC_TIM2: TIMER2 peripheral
    • LPC_TIM3: TIMER3 peripheral
[in]MatchChannelMatch channel, should be: 0..3
[in]MatchValueupdated match value
Returns:
None

Definition at line 505 of file lpc17xx_timer.c.