MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
RIT: Repetitive Interrupt Timer

Overview

The MCUXpresso SDK provides a driver for the Repetitive Interrupt Timer (RIT) of MCUXpresso SDK devices.

Function groups

The RIT driver supports operating the module as a time counter.

Initialization and deinitialization

The function RIT_Init() initializes the RIT with specified configurations. The function RIT_GetDefaultConfig() gets the default configurations. The initialization function configures the RIT operation normally in debug mode.

The function RIT_Deinit() disables the RIT timers and disables the module clock.

Timer read and write Operations

The function RIT_SetTimerCompare() sets the timer period in units of count. The timers count from 0 to the count value set here. The function RIT_SetMaskBit() sets some bit which is ignored in comparison between the compare and counter register.

The function RIT_GetCurrentTimerCount() reads the current timer counting value. This function returns the real-time timer counting value, in a range from 0 to a timer period.

The timer period operation functions takes the count value in ticks. User can call the utility macros provided in fsl_common.h to convert to microseconds or milliseconds

Start and Stop timer operations

The function RIT_StartTimer() starts the timer counting. After calling this function, the timer counts up to the counter value set earlier by using the RIT_SetTimerCompare() function. Each time the timer reaches the count value, it generates a trigger pulse and sets the interrupt flag and set the counter to zero/continue counting when RIT_SetCountAutoClear() set the Timer clear enable/disable.

The function RIT_StopTimer() stops the timer counting./* resets the timer's counter register.

Data Structures

struct  _rit_config
 RIT config structure. More...
 

Typedefs

typedef enum _rit_status_flags rit_status_flags_t
 List of RIT status flags.
 
typedef struct _rit_config rit_config_t
 RIT config structure. More...
 

Enumerations

enum  _rit_status_flags { kRIT_TimerFlag = RIT_CTRL_RITINT_MASK }
 List of RIT status flags. More...
 

Functions

static void RIT_ClearCounter (RIT_Type *base, bool enable)
 Sets the Timer Counter auto clear or not. More...
 
static void RIT_SetCountAutoClear (RIT_Type *base, bool enable)
 Sets the Timer Counter auto clear or not. More...
 

Driver version

#define FSL_RIT_DRIVER_VERSION   (MAKE_VERSION(2, 1, 1))
 Version 2.1.1.
 

Initialization and deinitialization

void RIT_Init (RIT_Type *base, const rit_config_t *config)
 Ungates the RIT clock, enables the RIT module, and configures the peripheral for basic operations. More...
 
void RIT_Deinit (RIT_Type *base)
 Gates the RIT clock and disables the RIT module. More...
 
void RIT_GetDefaultConfig (rit_config_t *config)
 Fills in the RIT configuration structure with the default settings. More...
 

Status Interface

static uint32_t RIT_GetStatusFlags (RIT_Type *base)
 Gets the RIT status flags. More...
 
static void RIT_ClearStatusFlags (RIT_Type *base, uint32_t mask)
 Clears the RIT status flags. More...
 

Read and Write the timer period

void RIT_SetTimerCompare (RIT_Type *base, uint64_t count)
 Sets the timer period in units of count. More...
 
void RIT_SetMaskBit (RIT_Type *base, uint64_t count)
 Sets the mask bit of count compare. More...
 
uint64_t RIT_GetCompareTimerCount (RIT_Type *base)
 Reads the current value of compare register. More...
 
uint64_t RIT_GetCounterTimerCount (RIT_Type *base)
 Reads the current timer counting value of counter register. More...
 
uint64_t RIT_GetMaskTimerCount (RIT_Type *base)
 Reads the current value of mask register. More...
 

Timer Start and Stop

static void RIT_StartTimer (RIT_Type *base)
 Starts the timer counting. More...
 
static void RIT_StopTimer (RIT_Type *base)
 Stops the timer counting. More...
 

Data Structure Documentation

struct _rit_config

This structure holds the configuration settings for the RIT peripheral. To initialize this structure to reasonable defaults, call the RIT_GetDefaultConfig() function and pass a pointer to your config structure instance.

The config struct can be made const so it resides in flash

Data Fields

bool enableRunInDebug
 true: The timer is halted when the processor is halted for debugging. More...
 

Field Documentation

bool _rit_config::enableRunInDebug

; false: Debug has no effect on the timer operation.

Typedef Documentation

typedef struct _rit_config rit_config_t

This structure holds the configuration settings for the RIT peripheral. To initialize this structure to reasonable defaults, call the RIT_GetDefaultConfig() function and pass a pointer to your config structure instance.

The config struct can be made const so it resides in flash

Enumeration Type Documentation

Enumerator
kRIT_TimerFlag 

Timer flag.

Function Documentation

void RIT_Init ( RIT_Type *  base,
const rit_config_t config 
)
Note
This API should be called at the beginning of the application using the RIT driver.
Parameters
baseRIT peripheral base address
configPointer to the user's RIT config structure
void RIT_Deinit ( RIT_Type *  base)
Parameters
baseRIT peripheral base address
void RIT_GetDefaultConfig ( rit_config_t config)

The default values are as follows.

* config->enableRunInDebug = false;
*
Parameters
configPointer to the onfiguration structure.
static uint32_t RIT_GetStatusFlags ( RIT_Type *  base)
inlinestatic
Parameters
baseRIT peripheral base address
Returns
The status flags. This is the logical OR of members of the enumeration rit_status_flags_t
static void RIT_ClearStatusFlags ( RIT_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseRIT peripheral base address
maskThe status flags to clear. This is a logical OR of members of the enumeration rit_status_flags_t
void RIT_SetTimerCompare ( RIT_Type *  base,
uint64_t  count 
)

This function sets the RI compare value. If the counter value equals to the compare value, it will generate an interrupt.

Note
Users can call the utility macros provided in fsl_common.h to convert to ticks
Parameters
baseRIT peripheral base address
countTimer period in units of ticks
void RIT_SetMaskBit ( RIT_Type *  base,
uint64_t  count 
)

This function sets the RI mask value. A 1 written to any bit will force the compare to be true for the corresponding bit of the counter and compare register (causes the comparison of the register bits to be always true).

Note
Users can call the utility macros provided in fsl_common.h to convert to ticks
Parameters
baseRIT peripheral base address
countTimer period in units of ticks
uint64_t RIT_GetCompareTimerCount ( RIT_Type *  base)
Note
Users can call the utility macros provided in fsl_common.h to convert ticks to usec or msec
Parameters
baseRIT peripheral base address
Returns
Current RI compare value
uint64_t RIT_GetCounterTimerCount ( RIT_Type *  base)

This function returns the real-time timer counting value, in a range from 0 to a timer period.

Note
Users can call the utility macros provided in fsl_common.h to convert ticks to usec or msec
Parameters
baseRIT peripheral base address
Returns
Current timer counting value in ticks
uint64_t RIT_GetMaskTimerCount ( RIT_Type *  base)
Note
Users can call the utility macros provided in fsl_common.h to convert ticks to usec or msec
Parameters
baseRIT peripheral base address
Returns
Current RI mask value
static void RIT_StartTimer ( RIT_Type *  base)
inlinestatic

After calling this function, timers load initial value(0U), count up to desired value or over-flow then the counter will count up again.

Parameters
baseRIT peripheral base address
static void RIT_StopTimer ( RIT_Type *  base)
inlinestatic

This function stop timer counting. Timer reload their new value after the next time they call the RIT_StartTimer.

Parameters
baseRIT peripheral base address
static void RIT_ClearCounter ( RIT_Type *  base,
bool  enable 
)
inlinestatic

This function set the counter auto clear or not whenever the counter value equals the masked compare value specified by the contents of COMPVAL/COMPVAL_H and MASK/MASK_H registers..

Deprecated:
Do not use this function. It has been superceded by RIT_SetCountAutoClear.
static void RIT_SetCountAutoClear ( RIT_Type *  base,
bool  enable 
)
inlinestatic

This function set the counter auto clear or not whenever the counter value equals the masked compare value specified by the contents of COMPVAL/COMPVAL_H and MASK/MASK_H registers..

Parameters
baseRIT peripheral base address
enableEnable/disable Counter auto clear when value equals the compare value.
  • true: Enable Counter auto clear.
  • false: Disable Counter auto clear.