Library for controlling an MCP4725 "12-Bit Digital-to-Analog Converter with EEPROM Memory". There is an accompanying test suite program "MCP_4725_Library_Test" that can be used to test this library.

Dependents:   IGGE_Power MCP4725_Library_Test MCP4725 SinWave ... more

Embed: (wiki syntax)

« Back to documentation index

MCP4725 Class Reference

MCP4725 class. More...

#include <mcp4725.h>

Public Types

enum  PowerMode { Normal = 0, PowerDown1k = 1, PowerDown100k = 2, PowerDown500k = 3 }
 

The device supports two types of power modes: normal and power-down.

More...
enum  BusFrequency { Standard100kHz, Fast400kHz, HighSpeed3_4Mhz }
 

The device supports 3 different I2C bus frequencies.

More...

Public Member Functions

 MCP4725 (PinName sda, PinName scl, BusFrequency bus_frequency, int device_address_bits)
 Create an mcp4725 I2C interface.
int read (enum PowerMode *mode, enum PowerMode *mode_eeprom, int *dac_value, int *dac_value_eeprom, bool *eeprom_write_in_progress)
 Read the contents of the dac register, the contents of eeprom, and if an eeprom write is currently active.

Protected Attributes

I2C _i2c_interface
 mbed I2C interface driver.
int _device_address
 The full i2c device address.

Detailed Description

MCP4725 class.

Used for interfacing with a mcp4725 12-Bit Digital-to-Analog Converter. To convert between the 12bit dac_value and Vout, use the following formula: dac_value = (Vout*4096/Vref), where Vout is the desired output analog voltage, Vref is the voltage connected to the Vdd pin of the device. Typically Vdd will be 3.3volts.

Note: There is an accompanying test suite program "MCP_4725_Library_Test" that can be used to test this library.

Definition at line 17 of file mcp4725.h.


Member Enumeration Documentation

The device supports 3 different I2C bus frequencies.

Enumerator:
Standard100kHz 

Standard 100kHz bus.

Fast400kHz 

Fast 400kHz bus.

HighSpeed3_4Mhz 

High Speed 3.4Mhz bus.

WARNING: the test suite fails for the mbed LPC1768 when this frequency is selected - not tested on other platforms.

Definition at line 36 of file mcp4725.h.

enum PowerMode

The device supports two types of power modes: normal and power-down.

In normal mode the device operates a normal digital to analog conversion. In power-down mode all digitial to analog conversion is stopped, resulting in the device using less power (typically 60nA). Also, in power down mode Vout will be pulled to ground using either a 1k, 100k or 500k ohm internal resistors.

Enumerator:
Normal 

In normal mode the device operates a normal D2A conversion.

PowerDown1k 

Enter the device into a power down mode, and pull Vout to ground using an internal 1k resistor.

PowerDown100k 

Enter the device into a power down mode, and pull Vout to ground using an internal 100k resistor.

PowerDown500k 

Enter the device into a power down mode, and pull Vout to ground using an internal 500k resistor.

Definition at line 24 of file mcp4725.h.


Constructor & Destructor Documentation

MCP4725 ( PinName  sda,
PinName  scl,
BusFrequency  bus_frequency,
int  device_address_bits 
)

Create an mcp4725 I2C interface.

Parameters:
sdaI2C data line pin
sclI2C clock line pin
bus_frequencythe frequency at which the I2C bus is running.
device_address_bitsThe 3bit address bits of the device.

Definition at line 4 of file mcp4725.cpp.


Member Function Documentation

int read ( enum PowerMode mode,
enum PowerMode mode_eeprom,
int *  dac_value,
int *  dac_value_eeprom,
bool *  eeprom_write_in_progress 
)

Read the contents of the dac register, the contents of eeprom, and if an eeprom write is currently active.

Parameters:
modePointer to variable to store the current power mode.
mode_eepromPointer to variable to store the power mode as is stored in eeprom.
dac_valuePointer to variable to store the current dac value.
dac_value_eepromPointer to variable to store the dac value as is stored in eeprom.
eeprom_write_in_progressPointer to variable to store the current eeprom write status.
Returns:
0 on success, non-0 on failure

Definition at line 27 of file mcp4725.cpp.


Field Documentation

int _device_address [protected]

The full i2c device address.

Definition at line 87 of file mcp4725.h.

I2C _i2c_interface [protected]

mbed I2C interface driver.

Definition at line 85 of file mcp4725.h.