All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
VREF: Voltage Reference Driver

## Overview

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.

1. Use the VREF_GetDefaultConfig() function.
2. 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.

vref_config_t vrefUserConfig;
VREF_GetDefaultConfig(&vrefUserConfig); /* Gets a default configuration. */
VREF_Init(VREF, &vrefUserConfig); /* Initializes and configures the VREF module */
/* Do something */
VREF_Deinit(VREF); /* De-initializes the VREF module */

## Data Structures

struct | vref_config_t
| The description structure for the VREF module. More...

## Enumerations

enum | vref_buffer_mode_t { kVREF_ModeBandgapOnly = 0U, kVREF_ModeTightRegulationBuffer = 2U }
| VREF modes. More...

## Driver version

#define | FSL_VREF_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))
| Version 2.1.0. More...

## VREF functional operation

void | VREF_Init (VREF_Type *base, const vref_config_t *config)
| Enables the clock gate and configures the VREF module according to the configuration structure. More...
void | VREF_Deinit (VREF_Type *base)
| Stops and disables the clock for the VREF module. More...
void | VREF_GetDefaultConfig (vref_config_t *config)
| Initializes the VREF configuration structure. More...
void | VREF_SetTrimVal (VREF_Type *base, uint8_t trimValue)
| Sets a TRIM value for reference voltage. More...
static uint8_t | VREF_GetTrimVal (VREF_Type *base)
| Reads the value of the TRIM meaning output voltage. More...

## Data Structure Documentation

struct vref_config_t

### Data Fields

vref_buffer_mode_t | bufferMode
| Buffer mode selection.

## Macro Definition Documentation

#define FSL_VREF_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))

## Enumeration Type Documentation

enum vref_buffer_mode_t

Enumerator
kVREF_ModeBandgapOnly | Bandgap on only, for stabilization and startup.
kVREF_ModeTightRegulationBuffer | Tight regulation buffer enabled.

## Function Documentation

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:

* vref_config_t vrefConfig;
* vrefConfig.bufferMode = kVREF_ModeHighPowerBuffer;
* vrefConfig.enableExternalVoltRef = false;
* vrefConfig.enableLowRef = false;
* VREF_Init(VREF, &vrefConfig);
*

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:

* vref_config_t vrefUserConfig;
* VREF_Init(VREF);
* VREF_GetDefaultConfig(&vrefUserConfig);
* ...
* VREF_Deinit(VREF);
*

Parameters

  base | VREF peripheral address.

void VREF_GetDefaultConfig | ( | vref_config_t * | config | ) |

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.