The MCUXpresso SDK provides a peripheral driver for the Crossbar Voltage Reference (VREF) block of MCUXpresso SDK devices.
The Voltage Reference(VREF) supplies 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.
VREF functional Operation
To configure the VREF driver, configure vref_config_t structure in one of two ways.
- Use the VREF_GetDefaultConfig() function.
- Set the parameter in the 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.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/vref
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 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. This is an 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. This is an example.
- Parameters
-
base | VREF peripheral address. |
This function initializes the VREF configuration structure to default values. This is an 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 the 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.