The KSDK provides a peripheral driver for the Crossbar Voltage Reference (VREF) block of Kinetis devices.
The Voltage Reference(VREF) is intended to supply an accurate 1.2 V voltage output that can be trimmed in 0.5 mV steps. VREF can be used in applications to provide a reference voltage to external devices and to internal analog peripherals, such as the ADC, DAC, or CMP. The voltage reference has operating modes that provide different levels of supply rejection and power consumption.
To configure the VREF driver, configure vref_config_t structure in one of two ways.
- Use the VREF_GetDefaultConfig() function.
- Sets the parameter in vref_config_t structure.
To initialize the VREF driver, call the VREF_Init() function and pass a pointer to the vref_config_t structure.
To de-initialize the VREF driver, call the VREF_Deinit() function.
Typical use case and example
This example shows how to generate a reference voltage by using the VREF module.
Enumerator |
---|
kVREF_ModeBandgapOnly |
Bandgap on only, for stabilization and startup.
|
kVREF_ModeTightRegulationBuffer |
Tight regulation buffer enabled.
|
void VREF_Init |
( |
VREF_Type * |
base, |
|
|
const vref_config_t * |
config |
|
) |
| |
This function must be called before calling all the other VREF driver functions, read/write registers, and configurations with user-defined settings. The example below shows how to set up vref_config_t parameters and how to call the VREF_Init function by passing in these parameters: Example:
* vrefConfig.
bufferMode = kVREF_ModeHighPowerBuffer;
* vrefConfig.enableExternalVoltRef = false;
* vrefConfig.enableLowRef = false;
*
- Parameters
-
base | VREF peripheral address. |
config | Pointer to the configuration structure. |
void VREF_Deinit |
( |
VREF_Type * |
base | ) |
|
This function should be called to shut down the module. Example:
- Parameters
-
base | VREF peripheral address. |
This function initializes the VREF configuration structure to a default value. Example:
* vrefConfig->
bufferMode = kVREF_ModeHighPowerBuffer;
* vrefConfig->enableExternalVoltRef = false;
* vrefConfig->enableLowRef = false;
*
- Parameters
-
config | Pointer to the initialization structure. |
void VREF_SetTrimVal |
( |
VREF_Type * |
base, |
|
|
uint8_t |
trimValue |
|
) |
| |
This function sets a TRIM value for reference voltage. Note that the TRIM value maximum is 0x3F.
- Parameters
-
base | VREF peripheral address. |
trimValue | Value of the trim register to set the output reference voltage (maximum 0x3F (6-bit)). |
static uint8_t VREF_GetTrimVal |
( |
VREF_Type * |
base | ) |
|
|
inlinestatic |
This function gets the TRIM value from the TRM register.
- Parameters
-
base | VREF peripheral address. |
- Returns
- Six-bit value of trim setting.