ADC  9.2
Analog to Digital Conversor library for the Teensy 3.5 microprocessor
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) 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). More...
 
void trim (uint8_t trim)
 Set the trim The change in the reference is about 0.5 mV per step. More...
 
void stop ()
 Stops the internal reference. More...
 
volatile bool isStable ()
 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. More...
 
volatile bool isOn ()
 Check if the internal reference is on. More...
 
void waitUntilStable ()
 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.
 

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.

Definition at line 113 of file VREF.h.

◆ 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.

Definition at line 105 of file VREF.h.

◆ 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
modecan 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.
trimadjusts the reference value, from 0 to 0x3F (63). Default is 32.

Definition at line 56 of file VREF.h.

◆ stop()

void VREF::stop ( )
inline

Stops the internal reference.

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

Definition at line 88 of file VREF.h.

◆ trim()

void VREF::trim ( uint8_t  trim)
inline

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

Parameters
trimadjusts the reference value, from 0 to 0x3F (63).

Definition at line 77 of file VREF.h.