Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method; 3) typical use case.
More...
Peripheral features and how this peripheral works ==================================================. The main function of the Programmable Delay module Block(PDB) mode is only to provide a controllable delay from the PWM SYNC output to the sampling trigger input of the programmable gain amplifier and ADC, as well as a controllable window synchronized with the PWM pulse, which is used in the definition of the analog comparator. Compare the analog signal in the window. Another main function of the PDB is to generate a sampling/filtering clock for the comparator, and another function of the PDB is to generate a PWM pulse synchronized with the PWM timer module.
Features
- 16-bit resolution with prescaler.
- Positive transition of trigger_in will initiate the counter.
- Supports two trigger_out signals. Each has an independently controlled delay from sync_in.
- Each trigger output is independently enabled.
- Trigger outputs can be ORed together to schedule two conversions from one input trigger event.
- Trigger outputs can be used to schedule precise edge placement for a pulsed output.
- Continuous trigger or single shot mode supported.
- Have faultA and faultC, when a fault input is detected, the appropriate Trigger A or Trigger C output is forced to the value defined by CTRLA[AINIT] of CTRLC[CINIT].
- Bypass mode supported.
- The input trigger bypasses the PDB logic entirely. It is possible to bypass any of the trigger outputs or all.
How this driver is designed to make this peripheral works.
The PDB driver provides a structure pdb_config_t, which contains all the programmable functions of the PDB. The PDB_Init() function configures the PDB function through its parameters. In addition to the initialization ioperation, the PDB driver also provides several function groups for function reconfiguration, such as interrupt enable/disable, bypass mode selection, delay function setting, counting function setting, and status flag acquisition and clearing. The functional groups are briefly described as follows:
- Initialization and deinitialization Interfaces The APIs in the functional group is used to initialize/deinitialize PDB module.
- PDB operation Interfaces The APIs in this functional group allows user Start/Stop and configure the PDB mode.
- Interrupt control interface The API in this function group can be used to enable/disable PDBinterrupts
- PDB status flag interface The API in this function group can be used to get/clear the PDB status
How to use this driver
- Initialize the PDB function by calling PDB_Init():
- PDB trigger output logic:
- The PDB module has five interrupt sources.
- If the PDB_EnableOverflowInterrupts interrupt is enabled, the counter rolls over interrupt is enable.
- PDB delay interrupt has four sources: delayA, delayB, delayC and delayD. You can select only their delay characteristics, or select their combined functions.
- Set the delay value of the enable trigger:
- There are four PDB delay registers, corresponding to the four trigger output signals, providing them with a delay trigger.
- Enable the counter, set the maximum count
- Set the maximum value of the count through the function PDB_SetModulusValue.
Typical Use Case
- PDB delay interrupt nitialize,take the enable delayA interrupt as an example:
* pdbConfigStruct.sPdbTriggerABOutputConfig.bEnableTrigger1 = true;
* pdbConfigStruct.bEnablePDB = true;
*
PDB_Init(DEMO_PDB_BASE, &pdbConfigStruct);
*