TIMER - Timer/Counter

Description

Timer/Counter (TIMER) Peripheral API.

The timer module consists of three main parts:

  • General timer configuration and enable control.
  • Compare/capture control.
  • Dead time insertion control (may not be available for all timers).

Data Structures

struct TIMER_Init_TypeDef
TIMER initialization structure.
struct TIMER_InitCC_TypeDef
TIMER compare/capture initialization structure.
struct TIMER_InitDTI_TypeDef
TIMER Dead Time Insertion (DTI) initialization structure.

Functions

void TIMER_Init (TIMER_TypeDef *timer, const TIMER_Init_TypeDef *init)
Initialize TIMER.
void TIMER_InitCC (TIMER_TypeDef *timer, unsigned int ch, const TIMER_InitCC_TypeDef *init)
Initialize the TIMER compare/capture channel.
void TIMER_InitDTI (TIMER_TypeDef *timer, const TIMER_InitDTI_TypeDef *init)
Initialize the TIMER DTI unit.
void TIMER_Reset (TIMER_TypeDef *timer)
Reset the TIMER to the same state that it was in after a hardware reset.
void TIMER_SyncWait (TIMER_TypeDef *timer)
Wait for pending synchronization to finish.
bool TIMER_Valid (const TIMER_TypeDef *ref)
Validate TIMER register block pointer.
bool TIMER_SupportsDTI (const TIMER_TypeDef *ref)
Check if TIMER is valid and supports Dead Timer Insertion (DTI).
uint32_t TIMER_MaxCount (const TIMER_TypeDef *ref)
Get the Max count of the timer.
uint32_t TIMER_CaptureGet (TIMER_TypeDef *timer, unsigned int ch)
Get compare/capture value for compare/capture channel.
uint32_t TIMER_CaptureBufGet (TIMER_TypeDef *timer, unsigned int ch)
Get buffered compare/capture value for compare/capture channel.
void TIMER_CompareBufSet (TIMER_TypeDef *timer, unsigned int ch, uint32_t val)
Set compare value buffer for compare/capture channel when operating in compare or PWM mode.
void TIMER_CompareSet (TIMER_TypeDef *timer, unsigned int ch, uint32_t val)
Set compare value for compare/capture channel when operating in compare or PWM mode.
uint32_t TIMER_CounterGet (TIMER_TypeDef *timer)
Get TIMER counter value.
void TIMER_CounterSet (TIMER_TypeDef *timer, uint32_t val)
Set TIMER counter value.
void TIMER_Enable (TIMER_TypeDef *timer, bool enable)
Start/stop TIMER.
void TIMER_EnableDTI (TIMER_TypeDef *timer, bool enable)
Enable or disable DTI unit.
uint32_t TIMER_GetDTIFault (TIMER_TypeDef *timer)
Get DTI fault source flags status.
void TIMER_ClearDTIFault (TIMER_TypeDef *timer, uint32_t flags)
Clear DTI fault source flags.
void TIMER_IntClear (TIMER_TypeDef *timer, uint32_t flags)
Clear one or more pending TIMER interrupts.
void TIMER_IntDisable (TIMER_TypeDef *timer, uint32_t flags)
Disable one or more TIMER interrupts.
void TIMER_IntEnable (TIMER_TypeDef *timer, uint32_t flags)
Enable one or more TIMER interrupts.
uint32_t TIMER_IntGet (TIMER_TypeDef *timer)
Get pending TIMER interrupt flags.
uint32_t TIMER_IntGetEnabled (TIMER_TypeDef *timer)
Get enabled and pending TIMER interrupt flags.
void TIMER_IntSet (TIMER_TypeDef *timer, uint32_t flags)
Set one or more pending TIMER interrupts from SW.
void TIMER_TopBufSet (TIMER_TypeDef *timer, uint32_t val)
Set top value buffer for timer.
uint32_t TIMER_TopGet (TIMER_TypeDef *timer)
Get top value setting for timer.
void TIMER_TopSet (TIMER_TypeDef *timer, uint32_t val)
Set top value for timer.

Macros

#define TIMER_INIT_DEFAULT
Default configuration for TIMER initialization structure.
#define TIMER_INITCC_DEFAULT
Default configuration for TIMER compare/capture initialization structure.
#define TIMER_INITDTI_DEFAULT
Default configuration for TIMER DTI initialization structure.

Typedefs

typedef uint8_t TIMER_PRSSEL_TypeDef
Peripheral Reflex System signal.

Enumerations

enum TIMER_CCMode_TypeDef {
timerCCModeOff = _TIMER_CC_CFG_MODE_OFF,
timerCCModeCapture = _TIMER_CC_CFG_MODE_INPUTCAPTURE,
timerCCModeCompare = _TIMER_CC_CFG_MODE_OUTPUTCOMPARE,
timerCCModePWM = _TIMER_CC_CFG_MODE_PWM
}
Timer compare/capture mode.
enum TIMER_ClkSel_TypeDef {
timerClkSelHFPerClk = _TIMER_CFG_CLKSEL_PRESCEM01GRPACLK,
timerClkSelCC1 = _TIMER_CFG_CLKSEL_CC1,
timerClkSelCascade = _TIMER_CFG_CLKSEL_TIMEROUF
}
Clock select.
enum TIMER_Edge_TypeDef {
timerEdgeRising = _TIMER_CC_CTRL_ICEDGE_RISING,
timerEdgeFalling = _TIMER_CC_CTRL_ICEDGE_FALLING,
timerEdgeBoth = _TIMER_CC_CTRL_ICEDGE_BOTH,
timerEdgeNone = _TIMER_CC_CTRL_ICEDGE_NONE
}
Input capture edge select.
enum TIMER_Event_TypeDef {
timerEventEveryEdge = _TIMER_CC_CTRL_ICEVCTRL_EVERYEDGE,
timerEventEvery2ndEdge = _TIMER_CC_CTRL_ICEVCTRL_EVERYSECONDEDGE,
timerEventRising = _TIMER_CC_CTRL_ICEVCTRL_RISING,
timerEventFalling = _TIMER_CC_CTRL_ICEVCTRL_FALLING
}
Input capture event control.
enum TIMER_InputAction_TypeDef {
timerInputActionNone = _TIMER_CTRL_FALLA_NONE,
timerInputActionStart = _TIMER_CTRL_FALLA_START,
timerInputActionStop = _TIMER_CTRL_FALLA_STOP,
timerInputActi