MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
PIT: Periodic Interrupt Timer (PIT) Driver

Read Guidance

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.

Driver Overview

 PIT Peripheral and Driver Overview
 Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method.
 
 The Driver Change Log
 The current PIT driver version is 2.2.0.
 

Data Structures

struct  pit_config_t
 PIT configuration structure. More...
 

Enumerations

enum  pit_prescaler_value_t {
  kPIT_PrescalerDivBy1 = 0x0U,
  kPIT_PrescalerDivBy2 = 0x1U,
  kPIT_PrescalerDivBy4 = 0x2U,
  kPIT_PrescalerDivBy8 = 0x3U,
  kPIT_PrescalerDivBy16 = 0x4U,
  kPIT_PrescalerDivBy32 = 0x5U,
  kPIT_PrescalerDivBy64 = 0x6U,
  kPIT_PrescalerDivBy128 = 0x7U,
  kPIT_PrescalerDivBy256 = 0x8U,
  kPIT_PrescalerDivBy512 = 0x9U,
  kPIT_PrescalerDivBy1024 = 0xAU,
  kPIT_PrescalerDivBy2048 = 0xBU,
  kPIT_PrescalerDivBy4096 = 0xCU,
  kPIT_PrescalerDivBy8192 = 0xDU,
  kPIT_PrescalerDivBy16384 = 0xEU,
  kPIT_PrescalerDivBy32768 = 0xFU
}
 PIT clock prescaler values. More...
 
enum  _pit_status_flags { kPIT_Timer_RollOverFlag = PIT_CTRL_PRF_MASK }
 List of PIT status flags. More...
 

Driver version

#define FSL_PIT_DRIVER_VERSION   (MAKE_VERSION(2, 2, 0))
 PIT Driver Version.
 

Initialization and deinitialization Interfaces

void PIT_Init (PIT_Type *base, const pit_config_t *psConfig)
 Ungates the PIT clock, configures the PIT features. More...
 
void PIT_Deinit (PIT_Type *base)
 Gates the PIT clock and disables the PIT module. More...
 
void PIT_GetDefaultConfig (pit_config_t *psConfig)
 Fill in the PIT config structure with the default settings. More...
 

PIT operation Interfaces

Sets the PIT clock prescaler.

Parameters
basePIT peripheral base address
ePrescalerTimer prescaler value
static void PIT_EnableSlaveMode (PIT_Type *base, bool bEnable)
 Enable/Disable PIT slave mode. More...
 
static void PIT_SetTimerPrescaler (PIT_Type *base, pit_prescaler_value_t ePrescaler)
 
static void PIT_SetTimerPeriod (PIT_Type *base, uint16_t u16PeriodCount)
 Sets the timer period in units of count. More...
 
static uint16_t PIT_GetCurrentTimerCount (PIT_Type *base)
 Reads the current timer counting value. More...
 
static void PIT_StartTimer (PIT_Type *base)
 Starts the timer counting. More...
 
static void PIT_StopTimer (PIT_Type *base)
 Stops the timer counting. More...
 

Interrupt control Interfaces

static void PIT_EnableInterrupt (PIT_Type *base)
 Enables the PIT interrupts. More...
 
static void PIT_DisableInterrupt (PIT_Type *base)
 Disables the selected PIT interrupts. More...
 

PIT Status Flag Interfaces.

static uint32_t PIT_GetStatusFlags (PIT_Type *base)
 Gets the PIT status flags. More...
 
static void PIT_ClearStatusFlags (PIT_Type *base)
 Clears the PIT status flags. More...
 

Data Structure Documentation

struct pit_config_t

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

The configuration structure can be made constant so it resides in flash.

Data Fields

pit_prescaler_value_t ePrescaler: 5
 Clock prescaler value.
 
bool bEnableInterrupt: 1
 Enable PIT Roll-Over Interrupt.
 
bool bEnableSlaveMode: 1
 
   Enable the PIT module in slave mode, in which mode the timer

will be triggered by master PIT enable. More...

 
bool bEnableTimer: 1
 PIT timer enable flag, which is false by default.
 
pit_count_clock_source_t eClockSource
 Specify the PIT count clock source.
 
uint16_t u16PeriodCount
 Timer period in clock cycles, Use macro definition MSEC_TO_COUNT to convert value in ms to count of ticks, the COP clock rate is source clock divide prescaler. More...
 

Field Documentation

bool pit_config_t::bEnableSlaveMode
uint16_t pit_config_t::u16PeriodCount

Enumeration Type Documentation

Enumerator
kPIT_PrescalerDivBy1 

Clock divided by 1.

kPIT_PrescalerDivBy2 

Clock divided by 2.

kPIT_PrescalerDivBy4 

Clock divided by 4.

kPIT_PrescalerDivBy8 

Clock divided by 8.

kPIT_PrescalerDivBy16 

Clock divided by 16.

kPIT_PrescalerDivBy32 

Clock divided by 32.

kPIT_PrescalerDivBy64 

Clock divided by 64.

kPIT_PrescalerDivBy128 

Clock divided by 128.

kPIT_PrescalerDivBy256 

Clock divided by 256.

kPIT_PrescalerDivBy512 

Clock divided by 512.

kPIT_PrescalerDivBy1024 

Clock divided by 1024.

kPIT_PrescalerDivBy2048 

Clock divided by 2048.

kPIT_PrescalerDivBy4096 

Clock divided by 4096.

kPIT_PrescalerDivBy8192 

Clock divided by 8192.

kPIT_PrescalerDivBy16384 

Clock divided by 16384.

kPIT_PrescalerDivBy32768 

Clock divided by 32768.

Enumerator
kPIT_Timer_RollOverFlag 

Timer roll over flag.

Function Documentation

void PIT_Init ( PIT_Type *  base,
const pit_config_t psConfig 
)

The configurations are:

  • Clock source selection for PIT module
  • Prescaler configuration to the input clock source
  • PIT period interval
  • PIT slave mode enable/disable
  • Interrupt enable/disable
  • PIT timer enable/disable
Note
This API should be called at the beginning of the application using the PIT driver and call PIT_StartTimer() API to start PIT timer.
Parameters
basePIT peripheral base address
psConfigPointer to the user's PIT config structure
void PIT_Deinit ( PIT_Type *  base)
Parameters
basePIT peripheral base address
void PIT_GetDefaultConfig ( pit_config_t psConfig)

This function initializes the PIT configuration structure to default values.

* psConfig->ePrescaler = kPIT_PrescalerDivBy1;
* psConfig->bEnableInterrupt = false;
* psConfig->bEnableSlaveMode = false;
* psConfig->bEnableTimer = false;
* psConfig->eClockSource = kPIT_CountClockSource0;
* psConfig->u16PeriodCount = 0xFFFFU;
*
Parameters
psConfigPointer to user's PIT config structure.
static void PIT_EnableSlaveMode ( PIT_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
basePIT peripheral base address
bEnableenable/disable slave mode
static void PIT_SetTimerPeriod ( PIT_Type *  base,
uint16_t  u16PeriodCount 
)
inlinestatic

Timers begin counting from 0 until it reaches the value set by this function, then it generates an interrupt and counter resumes counting from 0 again.

Note
Users can call the utility macros provided in fsl_common.h to convert to ticks.
Parameters
basePIT peripheral base address
countTimer period in units of ticks, use macro definition MSEC_TO_COUNT to convert value in ms to count of ticks, the PIT clock rate is source clock divide prescaler.
static uint16_t PIT_GetCurrentTimerCount ( PIT_Type *  base)
inlinestatic

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
basePIT peripheral base address
Returns
Current timer counting value in ticks, use macro definition COUNT_TO_MSEC to convert value in ticks to count of millisecond, the PIT clock rate is source clock divide prescaler.
static void PIT_StartTimer ( PIT_Type *  base)
inlinestatic

After calling this function, timers load period value, count down to 0 and then load the respective start value again. Each time a timer reaches 0, it generates a trigger pulse and sets the timeout interrupt flag.

Parameters
basePIT peripheral base address
static void PIT_StopTimer ( PIT_Type *  base)
inlinestatic

This function stops timer counting, and the counter remains at or returns to a 0 value.

Parameters
basePIT peripheral base address
static void PIT_EnableInterrupt ( PIT_Type *  base)
inlinestatic
Parameters
basePIT peripheral base address
static void PIT_DisableInterrupt ( PIT_Type *  base)
inlinestatic
Parameters
basePIT peripheral base address
static uint32_t PIT_GetStatusFlags ( PIT_Type *  base)
inlinestatic
Parameters
basePIT peripheral base address
Returns
The status flags. This is the logical OR of members of the enumeration _pit_status_flags
static void PIT_ClearStatusFlags ( PIT_Type *  base)
inlinestatic
Parameters
basePIT peripheral base address