MCUXpresso SDK API Reference Manual  Rev. 0
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. Timers counts from 0 to the count value set here. The function RIT_SetMaskBit() sets some bit which will be 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_ClearCounter() set the Timer clear enable/disable.

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

clear the count operations

The function RIT_ClearCounter() set the cuonter register to continue counting or clear the counter to zero when the the counter value equals the masked compare value specified by the contents of COMPVAL/COMPVAL_H and MASK/MASK_H registers.

Status

Provides functions to get and clear the RIT status.

Typical use case

RIT tick example

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/rit

Data Structures

struct  rit_config_t
 RIT config structure. More...
 

Enumerations

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

Driver version

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

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 timer counting 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 timer counting 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_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

Data Fields

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

Field Documentation

bool rit_config_t::enableRunInDebug

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

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 
)

Timers begin counting from the value set by this function until it XXXXXXX, then it counting the value again. Software must stop the counter before reloading it with a new value..

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 
)

Timers begin counting from the value set by this function until it XXXXXXX, then it counting the value again. Software must stop the counter before reloading it with a new value..

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)

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_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)

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
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. Each time a timer reaches desired value, it generates a XXXXXXX and sets XXXXXXX.

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
channelTimer channel number.