ADC: VREF Namespace Reference

ADC 8.0 Analog to Digital Conversor library for the Teensy 3.5 microprocessor

Functions
VREF Namespace Reference

Controls the Teensy internal voltage reference module (VREFV1) More...

## Functions
void | start (uint8_t mode=VREF_SC_MODE_LV_HIGHPOWERBUF, uint8_t trim=0x20)
| Start the 1.2V internal reference (if present) More...
void | trim (uint8_t trim)
| Set the trim. More...
void | stop ()
| Stops the internal reference. More...
volatile bool | isStable ()
| Check if the internal reference has stabilized. More...
volatile bool | isOn ()
| Check if the internal reference is on. More...
void | waitUntilStable ()
| Wait for the internal reference to stabilize. More...

## Detailed Description

Controls the Teensy internal voltage reference module (VREFV1)

## Function Documentation

## ◆ isOn()

volatile bool VREF::isOn | ( |  | ) |
| inline

Check if the internal reference is on.

Returns
  true if the VREF module is switched on.

## ◆ isStable()

volatile bool VREF::isStable | ( |  | ) |
| inline

Check if the internal reference has stabilized.

NOTE: This is valid only when the chop oscillator is not being used. By default the chop oscillator IS used, so wait the maximum start-up time of 35 ms (as per datasheet). waitUntilStable waits 35 us. This should be polled after enabling the reference after reset, after changing its buffer mode from VREF_SC_MODE_LV_BANDGAPONLY to any of the buffered modes, or after changing the trim.

Returns
  true if the VREF module is already in a stable condition and can be used.

## ◆ start()

void VREF::start | ( | uint8_t | mode = `VREF_SC_MODE_LV_HIGHPOWERBUF`,
|  | uint8_t | trim = `0x20`
| ) |  |
| inline

Start the 1.2V internal reference (if present)

This is called automatically by ADC_Module::setReference(ADC_REFERENCE::REF_1V2) Use it to switch on the internal reference on the VREF_OUT pin. You can measure it with adc->analogRead(ADC_INTERNAL_SOURCE::VREF_OUT).

Parameters

  mode | can be (these are defined in kinetis.h) VREF_SC_MODE_LV_BANDGAPONLY (0) for stand-by VREF_SC_MODE_LV_HIGHPOWERBUF (1) for high power buffer and VREF_SC_MODE_LV_LOWPOWERBUF (2) for low power buffer.
  trim | adjusts the reference value, from 0 to 0x3F (63). Default is 32.

## ◆ stop()

void VREF::stop | ( |  | ) |
| inline

Stops the internal reference.

This is called automatically by ADC_Module::setReference(ref) when ref is any other than REF_1V2

## ◆ trim()

void VREF::trim | ( | uint8_t | trim | ) |
| inline

Set the trim.

Set the trim, the change in the reference is about 0.5 mV per step.

Parameters

  trim | adjusts the reference value, from 0 to 0x3F (63).

## ◆ waitUntilStable()

void VREF::waitUntilStable | ( |  | ) |
| inline

Wait for the internal reference to stabilize.

This function can be called to wait for the internal reference to stabilize. It will block until the reference has stabilized, or return immediately if the reference is not enabled in the first place.