PMC Timer

Features

RTL8721Dx:
  • 2 sets of PMC Timers (each set contains 4 counters):

    • Sleep countdown counter

    • Deepsleep countdown counter

    • Wakeup counter

    • Reserved counter

  • 32-bit width down counter (stops automatically when reaching 0)

  • Configurable interrupt generation upon reaching 0

  • SDM32K clock source

  • Timer countdown value can be reset during operation

API

Raw API

PMCTIMER Exported Constants

PMCTIMER Device Config
RTL8721Dx:
/* PMC timer device instance for CM4/KM4 core. */
#define PMC_TIMER_DEV PMCTIMER_DEV0

/* PMC timer device instance for CM0/KM0 core. */
#define PMC_TIMER_DEV PMCTIMER_DEV1

/* PMC timer IRQ number for CM4/KM4 core. */
#define PMC_TIMER_IRQ PMC_TIMER0_IRQ

/* PMC timer IRQ number for CM0/KM0 core. */
#define PMC_TIMER_IRQ PMC_TIMER1_IRQ

/* PMC timer interrupt priority. */
#define PMC_TIMER_INT_PRIO INT_PRI_LOWEST
PMCTIMER Index
RTL8721Dx:
/* PMC timer index for system active time during sleep. */
#define PMC_SLEEP_TIMER 0

/* PMC timer index for system active time during deep sleep. */
#define PMC_DSLP_TIMER 1

/* PMC timer index for setting wakeup time during sleep. */
#define PMC_WAKEUP_TIMER 2

/* Reserved PMC timer index. */
#define PMC_RSVD_TIMER 3
PMCTIMER Valid Check
RTL8721Dx:
/* Bit mask for timer x configuration valid status. */
#define PMCT_BIT_TIM_VALIDx ((u32)(0x00000001 << (8 + x)))
PMCTIMER Reset
RTL8721Dx:
/* Bit mask to pulse reset timer x. */
#define PMCTRESET_BIT_TIMERx ((u32)(0x00000001 << (28 + x)))

PMCTIMER Exported Functions

RTL8721Dx:
u32 PMCTimerCnt_Get(PMCTIMER_TpyeDef *PMC_TIMER, u32 Timer_Idx)

Get the pmc timer current Counter value.

Parameters:
  • PMC_TIMER – The pointer of PMC TIMER DEV.

  • Timer_Idx – Timer index in PMC TIMER DEV. This parameter can be: 0 ~ 3.

Returns:

Current counter value.

void PMCTimerCnt_Reset(PMCTIMER_TpyeDef *PMC_TIMER, u32 Timer_Idx)

Reset the pmc timer count down value.

Parameters:
  • PMC_TIMER – The pointer of PMC TIMER DEV.

  • Timer_Idx – Timer index in PMC TIMER DEV. This parameter can be: 0 ~ 3.

void PMCTimerCnt_Set(PMCTIMER_TpyeDef *PMC_TIMER, u32 Timer_Idx, u32 NewValue)

Set the pmc timer count down value.

Parameters:
  • PMC_TIMER – The pointer of PMC TIMER DEV.

  • Timer_Idx – Timer index in PMC TIMER DEV. This parameter can be: 0 ~ 3.

  • NewValue – New counter.

void PMCTimer_Cmd(PMCTIMER_TpyeDef *PMC_TIMER, u32 Timer_Idx, bool NewState)

Enable or disable the pmc timer counter The pmc timer group contains 4 timers for each group, all runs at 32k.

Parameters:
  • PMC_TIMER – The pointer of PMC TIMER DEV.

  • Timer_Idx – Timer index in PMC TIMER DEV. This parameter can be: 0 ~ 3.

  • NewState – New state of the PMC timer counter. This parameter can be: ENABLE or DISABLE.

void PMCTimer_INTClear(PMCTIMER_TpyeDef *PMC_TIMER, u32 Timer_Idx)

Clear the pmc timer’s interrupt bits.

Parameters:
  • PMC_TIMER – The pointer of PMC TIMER DEV.

  • Timer_Idx – Timer index in PMC TIMER DEV. This parameter can be: 0 ~ 3.

void PMCTimer_INTConfig(PMCTIMER_TpyeDef *PMC_TIMER, u32 Timer_Idx, u32 NewState)

ENABLE/DISABLE the pmc timer’s interrupt bits.

Parameters:
  • PMC_TIMER – The pointer of PMC TIMER DEV.

  • Timer_Idx – Timer index in PMC TIMER DEV. This parameter can be: 0 ~ 3.

  • NewState – ENABLE or DISABLE.

u32 PMCTimer_Valid_Check(PMCTIMER_TpyeDef *PMC_TIMER, u32 Timer_Idx)

Check pmctimer current state.

Parameters:
  • PMC_TIMER – The pointer of PMC TIMER DEV.

  • Timer_Idx – Timer index in PMC TIMER DEV. This parameter can be: 0 ~ 3.

Returns:

The validation result:

  • TRUE: valid

  • FALSE: not valid