MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
PDB: Programmable Delay Block

Overview

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.

Modules

 PDB Peripheral and Driver Overview
 Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method; 3) typical use case.
 
 The Driver Change Log
 The current Pdb driver version is 2.0.0.
 

Data Structures

struct  pdb_trigger_output_logic_config_t
 configuring PDB trigger output logic. More...
 
struct  pdb_config_t
 PDB module config structure. More...
 

Enumerations

enum  pdb_prescaler_divider_t {
  kPDB_PrescalerDivider1 = 0U,
  kPDB_PrescalerDivider2,
  kPDB_PrescalerDivider4,
  kPDB_PrescalerDivider8,
  kPDB_PrescalerDivider16,
  kPDB_PrescalerDivider32,
  kPDB_PrescalerDivider64,
  kPDB_PrescalerDivider128
}
 Clock prescaler select. More...
 
enum  pdb_load_value_mode_t {
  kPDB_LoadValueImmediately = 0U,
  kPDB_LoadValueAfterEvent
}
 PDB load mode select. More...
 
enum  pdb_input_trigger_t {
  kPDB_TriggerInput0 = 0U,
  kPDB_TriggerInput1,
  kPDB_TriggerInput2,
  kPDB_TriggerInput3,
  kPDB_TriggerInput4,
  kPDB_TriggerInput5,
  kPDB_TriggerInput6,
  kPDB_TriggerSoftware
}
 Trigger Input Source Select. More...
 
enum  pdb_fault_length_t {
  kPDB_2IPBusClockCycles = 0U,
  kPDB_4IPBusClockCycles
}
 PDB fault length. More...
 
enum  pdb_fault_polarity_t {
  kPDB_FaultPolarity0 = 0U,
  kPDB_FaultPolarity1
}
 PDB fault polarity. More...
 
enum  pdb_trigger_output_t {
  kPDB_TriggerA = 0U,
  kPDB_TriggerB,
  kPDB_TriggerC,
  kPDB_TriggerD
}
 PDB trigger output signals. More...
 
enum  pdb_logic_t {
  kPDB_LogicA = 0U,
  kPDB_LogicC
}
 PDB trigger logic enumeration. More...
 
enum  pdb_init_value_t {
  kPDB_InitValue0 = 0U,
  kPDB_InitValue1
}
 PDB init value enumeration. More...
 
enum  _pdb_interrupt_enable {
  kPDB_EnableOverflowInterrupt = PDB_MCTRL_COIE_MASK,
  kPDB_EnableDelayAInterrupt = PDB_CTRLA_DAIE_MASK,
  kPDB_EnableDelayBInterrupt = PDB_CTRLA_DBIE_MASK,
  kPDB_EnableDelayCInterrupt = PDB_CTRLC_DCF_MASK,
  kPDB_EnableDelayDInterrupt = PDB_CTRLC_DDF_MASK
}
 The enumeration for PDB interrupt enable. More...
 
enum  _pdb_status_flags {
  kPDB_OverflowStatusFlag = PDB_MCTRL_COF_MASK,
  kPDB_DelayAStatusFlag = PDB_CTRLA_DAF_MASK,
  kPDB_DelayBStatusFlag = PDB_CTRLA_DBF_MASK,
  kPDB_DelayCStatusFlag = PDB_CTRLC_DCIE_MASK,
  kPDB_DelayDStatusFlag = PDB_CTRLC_DDIE_MASK
}
 The enumeration for PDB status flags. More...
 

Driver version

#define FSL_PDB_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 PDB driver version. More...
 

Initialization and deinitialization Interfaces

void PDB_Init (PDB_Type *base, const pdb_config_t *psConfig)
 Initializes the PDB module. More...
 
void PDB_Deinit (PDB_Type *base)
 De-initializes the PDB module. More...
 
void PDB_GetDefaultConfig (pdb_config_t *psConfig)
 Initializes the PDB user configuration structure. More...
 
void PDB_SetTriggerOutputLogicConfig (PDB_Type *base, pdb_logic_t eLogic, const pdb_trigger_output_logic_config_t *psConfig)
 Set the PDB trigger output logic. More...
 

Basic Counter

static void PDB_EnableModule (PDB_Type *base, bool bEnablePDBMode)
 Enable the PDB module. More...
 
static void PDB_EnableContinuousMode (PDB_Type *base, bool bEnableContinuousMode)
 Enables the PDB continuous mode. More...
 
static void PDB_DoSoftwareTrigger (PDB_Type *base)
 Triggers the PDB counter by software. More...
 
static void PDB_SetLoadOk (PDB_Type *base)
 Loads the counter values. More...
 
static bool PDB_GetPdbLdOk (PDB_Type *base)
 Get the PDB LDOK bit status. More...
 
static void PDB_EnableTriggerOutput (PDB_Type *base, pdb_trigger_output_t eTrigger, bool bEnable)
 Enable the PDB trigger output. More...
 
static void PDB_BypassTrigger (PDB_Type *base, pdb_trigger_output_t eTrigger, bool bValue)
 Bypass the PDB trigger output. More...
 
static void PDB_EnableTriggerConbineMode (PDB_Type *base, pdb_logic_t eLogic, bool bMode)
 Enable Trigger output A & B combined mode. More...
 
static void PDB_SetTriggerInitValue (PDB_Type *base, pdb_trigger_output_t eTrigger, pdb_init_value_t eInitValue)
 Initial trigger Value. More...
 
static void PDB_EnableFault (PDB_Type *base, pdb_logic_t eLogic, bool bEnable)
 Enable PDB fault feature. More...
 
static void PDB_FaultLength (PDB_Type *base, pdb_logic_t eLogic, pdb_fault_length_t ePdbFaultLength)
 Set the PDB fault length feature. More...
 
static void PDB_SetFaultPolarity (PDB_Type *base, pdb_logic_t eLogic, pdb_fault_polarity_t ePolarity)
 Set fault input polarity. More...
 
static void PDB_EnableInterrupts (PDB_Type *base, uint16_t u16Mask)
 The PDB interrupt is enabled according to the provided mask. More...
 
static void PDB_DisableInterrupts (PDB_Type *base, uint16_t u16Mask)
 The PDB interrupt is disabled according to the provided mask. More...
 
static void PDB_ClearStatusFlags (PDB_Type *base, uint16_t u16Mask)
 Clears the PDB status flags. More...
 
static uint16_t PDB_GetStatusFlags (PDB_Type *base)
 Gets the status flags of the PDB module. More...
 
static void PDB_SetTriggerDelay (PDB_Type *base, pdb_trigger_output_t eTrigger, uint16_t u16DelayValue)
 Sets the PDB trigger delay. More...
 
static void PDB_SetModulusValue (PDB_Type *base, uint16_t u16PeriodCount)
 Specifies the counter period. More...
 
static uint16_t PDB_GetCounterValue (PDB_Type *base)
 Gets the PDB counter's current value. More...
 

Data Structure Documentation

struct pdb_trigger_output_logic_config_t

PDB has two output logic and each output logic has two output trigger signals: trigger1 and trigger2.

Data Fields

bool bFaultEnable: 1U
 Set PDB fault input bit, true: PDB fault is enable; false: PDB fault is disable. More...
 
pdb_fault_polarity_t eFaultPolarity: 1U
 Selected the PDB fault polarity 0 or 1. More...
 
pdb_fault_length_t eFaultLength: 1U
 Selected the PDB fault length, 0: 2 IP bus clock cycles; 1: 4 IP bus clock cycles. More...
 
pdb_init_value_t eTriggerInitValue: 1U
 
                            Set fault bit forces the output from trigger logic : fault bit is

enabled or trigger logic output is set and the counter is reloaded. More...

 
bool bEnbleTriggerCombineOutput: 1U
 Trigger output select. More...
 
bool bEnableTrigger1: 1U
 Set trigger1 in each trigger output logic of PDB. More...
 
bool bEnableTrigger2: 1U
 Set trigger2 in each trigger output logic of PDB. More...
 
bool bBypassTrigger1: 1U
 Set bypass trigger1 in each trigger output logic of PDB. More...
 
bool bBypassTrigger2: 1U
 Set bypass trigger2 in each trigger output logic of PDB. More...
 
uint16_t uDelay1
 Set the delay of trigger1 in each trigger output logic of the PDB. More...
 
uint16_t uDelay2
 Set the delay of trigger2 in each trigger output logic of the PDB. More...
 

Field Documentation

bool pdb_trigger_output_logic_config_t::bFaultEnable
pdb_fault_polarity_t pdb_trigger_output_logic_config_t::eFaultPolarity
pdb_fault_length_t pdb_trigger_output_logic_config_t::eFaultLength
pdb_init_value_t pdb_trigger_output_logic_config_t::eTriggerInitValue
bool pdb_trigger_output_logic_config_t::bEnbleTriggerCombineOutput

true: Trigger1 and trigger2 Combine Output; false: Trigger1 and trigger2 function is only delay.

bool pdb_trigger_output_logic_config_t::bEnableTrigger1

true: PDB trigger1 is enable; false: PDB trigger1 is disable.

bool pdb_trigger_output_logic_config_t::bEnableTrigger2

true: PDB trigger2 is enable; false: PDB trigger2 is disable.

bool pdb_trigger_output_logic_config_t::bBypassTrigger1

true: PDB bypass trigger is enable; false: PDB bypass trigger is disable.

bool pdb_trigger_output_logic_config_t::bBypassTrigger2

true: PDB bypass trigger is enable; false: PDB bypass trigger is disable.

uint16_t pdb_trigger_output_logic_config_t::uDelay1
uint16_t pdb_trigger_output_logic_config_t::uDelay2
struct pdb_config_t

Data Fields

bool bEnableContinuousMode: 1U
 true: Module is in one-shot mode; false: Module is in continuous mode. More...
 
pdb_load_value_mode_t eLoadValueMode: 1U
 Configures PDB load value mode.0: load immediately; 1: load after the PDB counter rolls over or receives a trigger signal. More...
 
pdb_prescaler_divider_t ePrescalerDivider: 3U
 Configures PDB counter clock source prescaler. More...
 
pdb_input_trigger_t eInputTrigger: 3U
 Configures PDB trigger input source. More...
 
pdb_trigger_output_logic_config_t sPdbTriggerABOutputConfig
 Configure PDB trigger output logic A . More...
 
pdb_trigger_output_logic_config_t sPdbTriggerCDOutputConfig
 Configure PDB trigger output logic C. More...
 
uint16_t u16PeriodCount
 The period of the counter in terms of peripheral bus cycles. More...
 
bool bEnablePDB
 true: PDB module id enable; false: PDB module id disable. More...
 
uint16_t u16EnableInterruptMask
 PDB interrupt enable mask, logic OR of _pdb_interrupt_enable. More...
 

Field Documentation

bool pdb_config_t::bEnableContinuousMode
pdb_load_value_mode_t pdb_config_t::eLoadValueMode
pdb_prescaler_divider_t pdb_config_t::ePrescalerDivider
pdb_input_trigger_t pdb_config_t::eInputTrigger
pdb_trigger_output_logic_config_t pdb_config_t::sPdbTriggerABOutputConfig
pdb_trigger_output_logic_config_t pdb_config_t::sPdbTriggerCDOutputConfig
uint16_t pdb_config_t::u16PeriodCount
bool pdb_config_t::bEnablePDB
uint16_t pdb_config_t::u16EnableInterruptMask

Macro Definition Documentation

#define FSL_PDB_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Enumeration Type Documentation

The prescaler used for counting is selected by dividing the peripheral clock by the divisor.

Enumerator
kPDB_PrescalerDivider1 

Divider /1.

kPDB_PrescalerDivider2 

Divider /2.

kPDB_PrescalerDivider4 

Divider /4.

kPDB_PrescalerDivider8 

Divider /8.

kPDB_PrescalerDivider16 

Divider /16.

kPDB_PrescalerDivider32 

Divider /32.

kPDB_PrescalerDivider64 

Divider /64.

kPDB_PrescalerDivider128 

Divider /128.

Choose to load the DELAY and MOD registers into a set of buffers to take effect immediately or take effect after the counter is reversed and a trigger signal is received.

Enumerator
kPDB_LoadValueImmediately 

Load immediately after 1 is written to LDOK.

kPDB_LoadValueAfterEvent 

Load when the PDB counter rolls over or a trigger signal is received after 1 is written to LDOK.

Selects the trigger input source for the PDB. The trigger input source can be internal or the software trigger. When select kPDB_TriggerSoftware and the module is enabled, writing a one to MCTRL[SWTRIG] will trigger and software trigger. See chip configuration details for the actual PDB input trigger connections.

Enumerator
kPDB_TriggerInput0 

PDB input trigger 0.

kPDB_TriggerInput1 

PDB input trigger 1.

kPDB_TriggerInput2 

PDB input trigger 2.

kPDB_TriggerInput3 

PDB input trigger 3.

kPDB_TriggerInput4 

PDB input trigger 4.

kPDB_TriggerInput5 

PDB input trigger 5.

kPDB_TriggerInput6 

PDB input trigger 6.

kPDB_TriggerSoftware 

Software Trigger.

This bit is used to determine the minimum width requirement of the input fault for it to be recognized as a valid fault condition.

Enumerator
kPDB_2IPBusClockCycles 

Fault input must be active at least 2 IPBus clock cycles.

kPDB_4IPBusClockCycles 

Fault input must be active at least 4 IPBus clock cycles.

Enumerator
kPDB_FaultPolarity0 

A logic 0 on Fault pin indicates a fault condition.

kPDB_FaultPolarity1 

A logic 1 on Fault pin indicates a fault condition.

Enumerator
kPDB_TriggerA 

Trigger A.

kPDB_TriggerB 

Trigger B.

kPDB_TriggerC 

Trigger C.

kPDB_TriggerD 

Trigger D.

Each PDB instance has two trigger output logic and each output logic has two output signals.

Enumerator
kPDB_LogicA 

PDB trigger output logic A, has two output signals: triggerA and triggerB.

kPDB_LogicC 

PDB trigger output logic C, has two output signals: triggerC and triggerD.

Enumerator
kPDB_InitValue0 

PDB init value 0.

kPDB_InitValue1 

PDB init value 1.

Enumerator
kPDB_EnableOverflowInterrupt 

PDB overflow interrupt.

kPDB_EnableDelayAInterrupt 

PDB delayA interrupt.

kPDB_EnableDelayBInterrupt 

PDB delayB interrupt.

kPDB_EnableDelayCInterrupt 

PDB delayC interrupt.

kPDB_EnableDelayDInterrupt 

PDB delayD interrupt.

Enumerator
kPDB_OverflowStatusFlag 

PDB overflow interrupt.

kPDB_DelayAStatusFlag 

PDB delayA interrupt.

kPDB_DelayBStatusFlag 

PDB delayB interrupt.

kPDB_DelayCStatusFlag 

PDB delayC interrupt.

kPDB_DelayDStatusFlag 

PDB delayD interrupt.

Function Documentation

void PDB_Init ( PDB_Type *  base,
const pdb_config_t psConfig 
)

This function initializes the PDB module. The operations included are as follows.

  • Enable the clock for PDB instance.
  • Configure the PDB module.
  • Enable the PDB module.
Parameters
basePDB peripheral base address.
psConfigPointer to the configuration structure. See pdb_config_t.
void PDB_Deinit ( PDB_Type *  base)
Parameters
basePDB peripheral base address.
void PDB_GetDefaultConfig ( pdb_config_t psConfig)

This function initializes the user configuration structure to a default value. The default values are as follows.

* psConfig->bEnableContinuousMode = false;
* psConfig->eInputTrigger = kPDB_TriggerInput0;
* psConfig->eLoadValueMode = kPDB_LoadValueImmediately;
* psConfig->ePrescalerDivider = kPDB_PrescalerDivider1;
* psConfig->sPdbTriggerABOutputConfig.bBypassTrigger1 = false;
* psConfig->sPdbTriggerABOutputConfig.bBypassTrigger2 = false;
* psConfig->sPdbTriggerABOutputConfig.bEnableTrigger1 = false;
* psConfig->sPdbTriggerABOutputConfig.bEnableTrigger2 = false;
* psConfig->sPdbTriggerABOutputConfig.bEnbleTriggerCombineOutput = false;
* psConfig->sPdbTriggerABOutputConfig.eTriggerInitValue = kPDB_InitValue0;
* psConfig->sPdbTriggerABOutputConfig.eFaultLength = kPDB_2IPBusClockCycles;
* psConfig->sPdbTriggerABOutputConfig.eFaultPolarity = kPDB_FaultPolarity0;
* psConfig->sPdbTriggerABOutputConfig.bFaultEnable = false;
* psConfig->sPdbTriggerABOutputConfig.uDelay1 = 0xFFFFU;
* psConfig->sPdbTriggerABOutputConfig.uDelay2 = 0xFFFFU;
* psConfig->sPdbTriggerCDOutputConfig.bBypassTrigger1 = false;
* psConfig->sPdbTriggerCDOutputConfig.bBypassTrigger2 = false;
* psConfig->sPdbTriggerCDOutputConfig.bEnableTrigger1 = false;
* psConfig->sPdbTriggerCDOutputConfig.bEnableTrigger2 = false;
* psConfig->sPdbTriggerCDOutputConfig.bEnbleTriggerCombineOutput = false;
* psConfig->sPdbTriggerCDOutputConfig.eTriggerInitValue = kPDB_InitValue0;
* psConfig->sPdbTriggerCDOutputConfig.eFaultLength = kPDB_2IPBusClockCycles;
* psConfig->sPdbTriggerCDOutputConfig.eFaultPolarity = kPDB_FaultPolarity0;
* psConfig->sPdbTriggerCDOutputConfig.bFaultEnable = false;
* psConfig->sPdbTriggerCDOutputConfig.uDelay1 = 0xFFFFU;
* psConfig->sPdbTriggerCDOutputConfig.uDelay2 = 0xFFFFU;
* psConfig->u16PeriodCount = 0xFFFFU;
* psConfig->u16EnableInterruptMask = 0x0u;
* psConfig->bEnablePDB = false;
*
Parameters
psConfigPointer to configuration structure. See pdb_config_t.
void PDB_SetTriggerOutputLogicConfig ( PDB_Type *  base,
pdb_logic_t  eLogic,
const pdb_trigger_output_logic_config_t psConfig 
)
Parameters
basePDB peripheral base address.
eLogicindex for PDB trigger output logic instance. See pdb_logic_t.
psConfigPointer to the configuration structure. See pdb_trigger_output_logic_config_t.
static void PDB_EnableModule ( PDB_Type *  base,
bool  bEnablePDBMode 
)
inlinestatic
Parameters
basePDB peripheral base address.
bEnablePDBModeEnable the module or not.
static void PDB_EnableContinuousMode ( PDB_Type *  base,
bool  bEnableContinuousMode 
)
inlinestatic
Parameters
basePDB peripheral base address.
bEnableContinuousModeEnable the module or not.
static void PDB_DoSoftwareTrigger ( PDB_Type *  base)
inlinestatic
Parameters
basePDB peripheral base address.
static void PDB_SetLoadOk ( PDB_Type *  base)
inlinestatic

This function loads the counter values from the internal buffer.

Parameters
basePDB peripheral base address.
static bool PDB_GetPdbLdOk ( PDB_Type *  base)
inlinestatic
Parameters
basePDB peripheral base address.
Returns
Mask value for asserted flags. true: LDOK is set; false: LDOK is cleared.
static void PDB_EnableTriggerOutput ( PDB_Type *  base,
pdb_trigger_output_t  eTrigger,
bool  bEnable 
)
inlinestatic

When disabled, trigger output will be forced to 0.

Parameters
basePDB peripheral base address.
eTriggerindex for trigger instance. See pdb_trigger_output_t.
bEnablebEnable the triggers or not.
static void PDB_BypassTrigger ( PDB_Type *  base,
pdb_trigger_output_t  eTrigger,
bool  bValue 
)
inlinestatic

When bypass enabled, Trigger output is a single pulse created by the selected trigger source.

Parameters
basePDB peripheral base address.
eTriggerindex for trigger instance. See pdb_trigger_output_t.
bValueThe PDB bypassA mode enable or not.
static void PDB_EnableTriggerConbineMode ( PDB_Type *  base,
pdb_logic_t  eLogic,
bool  bMode 
)
inlinestatic

When enabled, Trigger A and Trigger B outputs are a function of combined DELAYA and DELAYB. Trigger A is an extended pulse and Trigger B is a dual pulse. When disabled, Trigger A is a function of DELAYA only. Trigger B is a function of DELAYB only.

Parameters
basePDB peripheral base address.
eLogicindex for PDB trigger output logic instance. See pdb_logic_t.
bModeThe trigger A output mode select.
static void PDB_SetTriggerInitValue ( PDB_Type *  base,
pdb_trigger_output_t  eTrigger,
pdb_init_value_t  eInitValue 
)
inlinestatic
Parameters
basePDB peripheral base address.
eTriggerindex for trigger instance. See pdb_trigger_output_t.
eInitValueset trigger init value. See pdb_init_value_t.
static void PDB_EnableFault ( PDB_Type *  base,
pdb_logic_t  eLogic,
bool  bEnable 
)
inlinestatic
Parameters
basePDB peripheral base address.
eLogicindex for PDB trigger output logic instance. See pdb_logic_t.
bEnableEnable the interrupts or not.
static void PDB_FaultLength ( PDB_Type *  base,
pdb_logic_t  eLogic,
pdb_fault_length_t  ePdbFaultLength 
)
inlinestatic

This bit is used to determine the minimum width requirement of the input fault for it to be recognized as a valid fault condition.

Parameters
basePDB peripheral base address.
eLogicindex for PDB trigger output logic instance. See pdb_logic_t.
ePdbFaultLengthSet the PDB fault length. See pdb_fault_length_t.
static void PDB_SetFaultPolarity ( PDB_Type *  base,
pdb_logic_t  eLogic,
pdb_fault_polarity_t  ePolarity 
)
inlinestatic
Parameters
basePDB peripheral base address.
eLogicindex for PDB trigger output logic instance. See pdb_logic_t.
ePolaritySet the PDB fault polarity. See pdb_fault_polarity_t.
static void PDB_EnableInterrupts ( PDB_Type *  base,
uint16_t  u16Mask 
)
inlinestatic
Parameters
basePDB peripheral base address.
u16MaskThe PDB interrupts to enable. Logical OR of _pdb_interrupt_enable.
static void PDB_DisableInterrupts ( PDB_Type *  base,
uint16_t  u16Mask 
)
inlinestatic
Parameters
basePDB peripheral base address.
u16MaskThe PDB interrupts to disable. Logical OR of _pdb_interrupt_enable.
static void PDB_ClearStatusFlags ( PDB_Type *  base,
uint16_t  u16Mask 
)
inlinestatic
Parameters
basePDB peripheral base address.
u16MaskThe status flags to clear. This is the logical OR of _pdb_status_flags.
static uint16_t PDB_GetStatusFlags ( PDB_Type *  base)
inlinestatic
Parameters
basePDB peripheral base address.
Returns
Mask value for asserted flags.
static void PDB_SetTriggerDelay ( PDB_Type *  base,
pdb_trigger_output_t  eTrigger,
uint16_t  u16DelayValue 
)
inlinestatic

Write logic 1 to the MCTRL[LDMOD] bit, any value written to the DELAY register will be ignored until the value in these registers is loaded into the buffer; and this bit is 0, we need to manually set it to 1.

Parameters
basePDB peripheral base address.
eTriggerindex for trigger instance. See pdb_trigger_output_t.
u16DelayValueSetting value for PDB counter delay event. 16-bit is available.
static void PDB_SetModulusValue ( PDB_Type *  base,
uint16_t  u16PeriodCount 
)
inlinestatic

Write logic 1 to the MCTRL[LDMOD] bit, any value written to the MOD register will be ignored until the value in these registers is loaded into the buffer; and this bit is 0, we need to manually set it to 1.

Parameters
basePDB peripheral base address.
u16PeriodCountSetting value for the modulus. 16-bit is available.
static uint16_t PDB_GetCounterValue ( PDB_Type *  base)
inlinestatic
Parameters
basePDB peripheral base address.
Returns
PDB counter's current value.