MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Wtimer

Overview

Files

file  fsl_wtimer.h
 

Driver version

Wake timers provide wakeup capabilities in sleep modes where 32KHz clock is kept active. Wake timer 0 is a 48bit based counter while wake timer 1 is 32bit based counter. A special API functions WTIMER_StartTimerLarge(0 and WTIMER_StartTimerLarge() are provided to access the 48bit counter. The Wake timer 1 is to be used bu the PWRM framework. It shall not be used by the Application directly. API provides the capability to enable and disable interrupts. The application shall implement the Wake timer ISR on its side. The wake timer ISR prototypes are : void WAKE_UP_TIMER0_IRQHandler(void); and void WAKE_UP_TIMER1_IRQHandler(void); The Application shall correctly the 32KHz source amoung the FRO32 or Crystal 32KHz using CLOCK_EnableClock() API in fsl_clock.h The APi provides the capability to calibrate the 32KHz clock versus a high reference clock (32MHz crystal).

#define FSL_WTIMER_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 Version 2.0.0.
 

Initialization and deinitialization

void WTIMER_Init (void)
 Enable the clocks to the peripheral (functional clock and AHB clock) More...
 
void WTIMER_DeInit (void)
 Disable the clocks to the peripheral (functional clock and AHB clock) More...
 
void WTIMER_EnableInterrupts (WTIMER_timer_id_t timer_id)
 Enable the selected Timer interrupts. More...
 
WTIMER_status_t WTIMER_GetStatusFlags (WTIMER_timer_id_t timer_id)
 Gets the Timer status flags. More...
 
void WTIMER_ClearStatusFlags (WTIMER_timer_id_t timer_id)
 Clears the Timer status flags if expired and clear the pendng interrupt if active it needs to be called in ISR. More...
 
void WTIMER_StartTimer (WTIMER_timer_id_t timer_id, uint32_t count)
 Starts the Timer counter. More...
 
void WTIMER_StopTimer (WTIMER_timer_id_t timer_id)
 Stops the Timer counter. More...
 
uint32_t WTIMER_CalibrateTimer (void)
 Calibrate the 32KHz clock to be used by the wake timer versus the 32MHz crystal clock source The Applicaton shall switches OFF the 32MHz clock if no longer used by the chip using CLOCK_DisableClock() in fsl_clock.h. More...
 
uint32_t WTIMER_ReadTimer (WTIMER_timer_id_t timer_id)
 Read the LSB counter of the wake timer This API is unsafe. More...
 
uint32_t WTIMER_ReadTimerSafe (WTIMER_timer_id_t timer_id)
 Read the LSB counter of the wake timer API checks the next counter update (next 32KHz clock edge) so the value is uptodate Important note : The counter shall be running otherwise, the API gets locked and never return. More...
 

Function Documentation

void WTIMER_Init ( void  )
Note
This function does not reset the wake timer peripheral. Wake timer reset is done in PWRM_vColdStart() from the PWRM framework module if integrated If PWRM framework module is integrated, WTIMER_Init() is called in PWRM_vInit() for power modes with Oscillator ON.
void WTIMER_DeInit ( void  )
Note
This function does not reset the wake timer peripheral.
void WTIMER_EnableInterrupts ( WTIMER_timer_id_t  timer_id)

The application shall implement the Wake timer ISR

Parameters
timer_idWtimer Id
WTIMER_status_t WTIMER_GetStatusFlags ( WTIMER_timer_id_t  timer_id)
Parameters
timer_idWtimer Id
Returns
The status flags.
void WTIMER_ClearStatusFlags ( WTIMER_timer_id_t  timer_id)
Parameters
timer_idWtimer Id
void WTIMER_StartTimer ( WTIMER_timer_id_t  timer_id,
uint32_t  count 
)

The function performs: -stop the timer if running, clear the status and interrupt flag if set (WTIMER_ClearStatusFlags()) -set the counter value -start the timer

Parameters
timer_idWtimer Id
countnumber of 32KHz clock periods before expiration
void WTIMER_StopTimer ( WTIMER_timer_id_t  timer_id)
Parameters
timer_idWtimer Id
uint32_t WTIMER_CalibrateTimer ( void  )
Returns
32KHz clock frequency (number of 32KHz clock in one sec) - expect to have 32768
uint32_t WTIMER_ReadTimer ( WTIMER_timer_id_t  timer_id)

If the counter has just been started, the counter value may not be up to date until the next 32KHz clock edge. Use WTIMER_ReadTimerSafe() instead

Parameters
timer_idWtimer Id
Returns
counter value - number of ticks before expiration if running
uint32_t WTIMER_ReadTimerSafe ( WTIMER_timer_id_t  timer_id)
Parameters
timer_idWtimer Id
Returns
32KHz clock frequency (number of 32KHz clock in one sec) - expect to have 32768