The MCP4725 is an analogue DAC - it generates a voltage at its output
just like a potentiometer. The difference is that this chip sets the
output via digital control with a voltage buffer that is controlled from
an I2C serial interface.
It outputs a proportion of the
input voltage. Since it's a 12bit device its
resolution is Vref/4096. So you can choose very fine steps dividing down
from the reference.
It also contains an EEPROM memory so the device can power up immediately to an output voltage
without requiring programming each time. You obviously have
to program it the first time, but after that it remembers the voltage
This page also compares the MCP4726 with the MCP4725 since they are very
similar devices. The main difference is that the 4726 has a reference
voltage input - there are other differences as well.
MCP4725 Breakout board
In the breakout board, the three solder blobs labelled ADDR let you control the value of A0 which changes the i2C address of the chip. The chip is upside down with A0 at bottom left which
connects to the middle 'ADDR' solder blob. A0 is used to select from one
of two I2C addresses.
The resistor to the right of the solder blobs should be a 1k pull-down but it was put in
series from GND to the middle solder blob, so it does nothing - that 1k
is useless - that means you must solder something otherwise the address input is left floating and you may get random operation!
You have to solder either the top 2 blobs (A0=0), or the bottom two
blobs (A0=1) forming a solder bridge, otherwise A0 is left floating. Don't solder them all together - it will short the
The two top resistors are 4k7 and pull-ups for SDA and SCL. On the
back there are "cut-tracks" that can be cut to isolate these resistors.
Cut these "cut tracks" if there are already pull-ups with other attached
 For more devices on a single I2C bus order pre-programmed devices.
 A number below 1 LSB means no codes are missed.
 Code Range 100 to 4000 (see Accuracy)
The MCP4725 has a single A0 address input pin, meaning that only two
devices can be placed on a single I2C bus. However there is a workaround
that allows you to place 8 devices on a single bus.
Warning: You can only use two devices on a single I2C bus unless...
The work around is that you must order different versions of the
MCP4725 that have hard coded A1 and A2 address bits programmed in at the
time of manufacture.
MCP4725 Address mapping
The lower three bits of the address consist of the three digital
inputs A2, A1, A0 while the upper bits are fixed at 1100xxx. A1
and A2 are assigned at manufacture and will usually be zero.
The the last
bit( LSB ' 'L), sent following the address bits, is ignored as it is the read write bit (R/Wn). Therefore
the addresses with only A0 available as an address control are:
For each device you can set A0 to one or zero. The rest (A1 and A2) are specified on purchase.
There are two write commands and one read command (Datasheet Table 6-2):
Fast mode DAC register write.
Write DAC control register (optional EEPROM write).
The first command "Fst Mode" (Datasheet Figure 6-1) is a fast update command and
writes only to the DAC register and does not update the EEPROM. It also
uses a different data format to the second. It allows the data to fit
into two bytes whereas the second format uses three.
1st command uses 2 data bytes making 3 I2C packets (including address).
2nd command uses 3 data bytes making 4 I2C packets (including address).
Confusingly when you use the second command (Datasheet Figure 6-2)
and set C2,C1,C0 to 010 it has the same effect as the first command and
just sets the DAC registers but does not program the EEPROM.
The real use of the second command is to update the EEPROM as well
when C2,C1,C0 = 011. In this case a new command can not be used until
the EEPROM has finished being written.
Warning: An EEPROM update takes up to 50ms and blocks operation.
EEPROM write can take up to 50ms (typically 20ms ) and no other
action is allowed until the update is completed (Read the RDY/BSYn flag
To avoid really slow operation, use the first command that does not write to the EEPROM - this is the "Fast Update" command.
To improve the speed of operation a bit more you can repeat the data
packet so you don't have to stop and start the I2C. So instead of a stop
bit at the end of an I2C
transaction you just repeat the two data bytes that update the DAC
output. The output is then continuously updated at the end of every
second I2C ACK signal.
This means you can update the output at a rate determined by the
transmission speed of 2 I2C packets (an I2C packet holds 8 bits and you
need 12 bits so 2 packets are needed).
Note: I2C operation is not that fast. Speed test results are here.
For reading data back, you set the R/Wn bit in the first I2C packet high (Datasheet Figure 6-3).
Then you read back 5 bytes from the MCP4725. The first byte contains the
RDY/BSYn bit which is used to check if an EEPROM write has completed.
There are several factors that contribute to the MCP4725 accuracy:
Warning: The code range used is the biggest factor affecting accuracy.
The datasheet suggests that to get 1% accuracy use only codes between 100 and 4900 due to opamp saturation.
At the top and bottom end of MCP4725 DAC codes, the linearity of the
output becomes worse. The recommended area of use is for a code output
range of 100 to 4000, which is the range defined for measurement of INL
This is the datasheet diagram showing the transfer function across
the whole range of codes. You can see that at higher codes the
transfer function departs from the straight line. For codes below
100 the output is also non linear (not shown). This is why INL and
DNL measurements are defined only for codes 100 ~ 4000.
Once you have setup the desired voltage, the beauty of the chip is that
you can program the internal EEPROM to output the same voltage at every
power-up .i.e. you calibrate the unit and it is set-and-forget.
There are several uses for the chip:
Repeated output (remembers output after power down).
Waveform generation (very slow with Arduino Uno - use DSP e.g. ESP32).
The ideal use for this chip is to setup fixed output voltages for
calibration of a unit. Once you have calibrated the system the chip will
remember the output setting and output the same voltage at power up.
Digital Power Supply
Another use could be in a digital power supply where you want the
output to keep the same value that was last set i.e a programmable power
You could use it to generate waveforms (fairly slow) but it can you can speed it up using the fast mode DAC write command.
Using the I2C 3.4MHz
mode would make the output dependent only on the chip specification of
slew rate and settling time, and command used (plus a bit more for the serial interface
update). Don't forget processor speed of update i.e. how
fast round the main loop (or use and interrupt generated update).
No separate reference voltage input.
No Synchronous update.
The Voltage Reference is the Supply
One problem is that the chip uses the supply voltage as the reference
voltage source. Supply voltage chips generally have a tolerance, specified by the manufacturer of between
2% and 10% so you can end up with this tolerance at the output. (See this page for some measurements on 5V supply variation)
You could get around this by the MCP4725 with an accurate voltage
reference at the VDD pin, but then you need to make sure that the reference is
capable of supplying all attached chips with enough current.
Alternatively use the MCP4726 which also has an optional buffer amplifier at the reference input pin.
The addressing scheme is discussed here (it is a bit limited).
This is a subtle disadvantage. You can not update the outputs of
multiple MCP4725 at the same time. This is not really a disadvantage of
the chip - it is just something you might not think about unless you
really need this feature.
You can only update each MCP4725 using and individual I2C sequence,
so if you have 8 chips it is going to take 8 I2C data packets which
takes time. If you really need synchronous updates use the MCP4728 or MCP4922 that have a hardware update control signal.
Then enter MCP4725 in the search box which will show the result:
Adafruit_MCP4725 by Adafruit Version 1.0.0 - Click Install.
You can see that the library is installed by going to Menu:
Sketch-->Include Library, scroll down in the drop down box that appears and
you will see an entry labelled : Adafruit MCP4725 Library.
The code in this library always uses the 400kHz I2C mode. It
does this by storing the current TWBR value and restoring it at the end
of the function setVoltage(). So whatever you do you can't change the
speed unless you edit the library code (Adafruit_MCP4725.cpp). This is probably about as fast as the UNO can go.
uint8_t twbrback = TWBR;
TWBR = ((F_CPU / 400000L) - 16) / 2; // Set I2C frequency to 400kHz
The definition TWBR is set elsewhere to indicate that the processor has a TWBR register.
Warning: Don't continuously write to the EEPROM as it has a lifetime.
The second parameter, in the setVoltage() function, writes the EEPROM if set true.
Arduino Uno R3/Arduino Nano.
MCP4725 breakout board (Use A0 solder bridge to GND).
For testing use an Arduino Uno and connect it as follows:
This example generates a sinewave output using stored values that are
programmed into the Flash memory. Note that this does not use the fast
method mentioned here. The Arduino output is using I2C at 400kHz.
This sketch is setup using 32 intervals in a complete sine wave (16 steps from top to bottom). So
is going through 360/32 degrees and obtaining a DAC result for each
angle. It is setup with 1V per division and has a frequency of 218Hz. If
you used fast updates you would get slightly better than double the frequency.
Timebase: 500us/div, Yellow 1V/div.
For this interval each step represents 5/16 = 312mV. The chip is capable of a resolution of 4096 giving steps of 5/4096 = 1.2mV.
The second waveform shows the I2C clock. You can see that there are
four 9 bit I2C packets per update. The clock period is 2.5us, 1/T =
Notice also how there is noise on the output (image below) - this could be
reduced by power supply filtering, output filtering and board
layout (possibly). The screen shot below has the yellow channel at 50mV
per division. It shows noise from the I2C packets imposed on the output
Timebase: 10us/div, Blue 10v/Div, Yellow 50mV/div.
The implication is, that for accuracy the I2C interface should be
shutdown while a measurement is made (when using the MCP4725 as a
Filtering the output using a 10k and 100nF to GND (fc=159Hz) gives the following waveforms:
The 400kHz signal is attenuated out but there is still system noise.
Timebase: 10us/div, Yellow 10v/Div, Blue 50mV/div.
The full waveform is here (10k ,100nF):
You can see that the above output (blue) is phase shifted and
attenuated. This is a problem if you want to generate waveforms. If you
only need a dc output then noise will be filtered out better by the 10k
and 100nF filter. The effect will be a longer settling time after
changing the DAC output.
If you relax the filter to 10k and 100n Fc=1.59kHz. Then you get an
output that is closer to the original i.e. it is not attenuated and not
phase shifted as much because the corner frequency of the filter (Fc) is
a long way from 218Hz. However, system noise will be increased.
Timebase:500us/div, Yellow 1V/div, Blue 1V/div.
Note the output of the voltage regulator is 4.76V.
Theoretical maximum speed
Approximately how fast could this chip go in generating a 32 bit sinewave?
The sinewave goes through a cycle of 32 bits from max to min, and then to max again, so from top to bottom there are 16 steps.
Ignoring slew rate, and settling time, and processor time. From the
waveforms you can see that 4*9=36 bits must be output. If the clock is 3.4Mhz (MAX I2C speed)
then this would take 39*(1/3.4e6) = 11.47us.
To generate 32 segments will take 32*11.47e-6=367us.
That generates a frequency of 1/367e-6 = 2.724kHz.
This is the maximum theoretical sine wave (using normal Stop/Start I2C transmission) - remember this is a low
resolution sine wave and would slow down if more segments were needed.
Warning: This is a low resolution sinewave. More steps = slower.
You could increase the speed using the fast mode by 25% (sending only 3 packets) ~ 3.4kHz.
If you use the continuous update method where you don't release the I2C
bus, then you can double the output rate to 5.9kHz. This output
generator should be controlled from a priority interrupt routine.
Warning: Calculations assume the processor is dedicated to this task!
This section allows you to compare the MCP4726 to the MPC4725.
The MCP4726 is nearly the same as the MCP4725 but has two new features:
An external reference input with optional input buffer.
A gain selectable opamp.
By adding the external reference input, the address pin A0 is lost, so
the device has an even more restricted address capability (you have to
order pre-programmed devices if you want more than one device on a
single I2C bus).
From the above diagram you can see that the reference section and opamp have been enhanced.
For the reference you can select between:
Power supply as reference.
Unbuffered input pin as reference.
Buffered input pin as reference.
The first is obvious!
When using the second option (unbuffered input) the voltage source
must be able to drive enough current into the ~210kOhm (±20%) resistor
The third option is used when you can't load the voltage reference
source (you should try to use a source that can drive enough current).
Using the buffer amplifier does result in a slight reduction in input
range (10mV ~ VDD-40mV). the buffer amplifier has low noise and low offset voltage but they are not zero
The opamp has a selectable gain of 1 or 2. So if you have a low
voltage reference e.g. 1.25V you can double it up as long as the voltage
input at the reference voltage pin remains below Vdd/2.
MCP4726 compared to MCP4725
The MCP4726 is virtually identical to the MCP4725 but has two new features:
An external reference input.
A gain selectable opamp (x1 or x2 gain).
The MPC4726 addresses the main problem of the MCP4725 - that the power supply
is used as a reference. This is not the best thing to use if you want to
create a highly accurate system.
What you really want is a separate input pin to supply your own
defined and accurate reference and this is exactly what has happened in
the MCP4726. However, a sacrifice was made and that was to change
the function of a pin.
The only pin that can be replaced (in the same package size) is the A0 (address input pin).
This pin has been turned into the reference input pin in the MCP4726.
 For more devices on a single I2C bus order pre-programmed devices.
 A number below 1 LSB means no codes are missed.
 Code Range 100 to 4000 (see Accuracy)
Note: Other parameters specific to the MCP4726 are not listed here.
Note: Current consumed is more than the MCP4725 as more is going on.
MCP4726 Accepts an external reference voltage the MCP4725 does not.
They both use the same package: SOT-23-6.
Selectable gain opamp (G=1 or 2).
Very low typical power down current (only a bit worse than the MCP4725).
Its address capability it is even less capable than the
MCP4725 and does not have an address input. In this case to get more
than one chip on a single address bus requires that you buy different
devices with pre-programmed addresses built in.
You use up to 8 devices on the same I2C bus but must specify the A0, A1 and A2 address bits on ordering.
These chips (MCP4725 and MCP4726) are very useful for sprinkling around a board as they
occupy very little board area, and can be tied to a single I2C bus. You
can use them to setup calibration for analogue circuits with ease.
Note: The (typical) power down current is very low for these chips.
The only fly-in-the-ointment is that for more than 2 (MCP4725), and
for more than 1 (MCP4726) you have to order differently programmed
devices from the manufacture in order to make use of the full address
range of each chip (max 8 of either type on a single I2C bus).
For a large firm, this is just a procurement exercise, then feeding the
chips into the correct slot on the pick and place machine. If you are
going to debug this system, it is another matter. You'll be sitting on
the bench figuring out which SMD device is which, and trying to keep it
all under control.
You can find out more about the MCP4728 here, where you'll see how it incorporates ideas from the MCP4726 and MCP4725.
The MCP4725 is not really useful as a waveform generator and for the
Arduino Uno the maximum output frequency is 218Hz for a 16 step
If you increase the number of
steps to 4096 it is going to take a very long time to output a waveform
so it will have even lower frequency. Testing shows a 9 bit waveform
512 elements (256 top to bottom) gives: 13.66Hz.
However the examples in this document use a maximum I2C speed of
400kHz (dependent on the Arduino Uno speed).
The chip is capable of a 3.4MHz speed. If you used a faster processor
then the output rate would be increased but does this make much
difference? The rate would increase from 400kHz to 3400kHz which is a factor
of 8.5. So the above outputs would increase from 218Hz to 1853Hz (16
steps), and 13.66Hz to 116.11Hz (256 steps). So in fact these are still
not impressive speeds.
As you can see from the "Theoretical maximum speed"
even using a DSP processor will only result in a maximum output rate of
2.7kHz (this is again generating only a 32 bit sinewave with 16 steps
top to bottom). You can push this to 5.9kHz with continuous output mode
but the processor is dedicated to this task alone.
Alternatively use an SPI version of the DAC: MCP4922.
However, even with that device the theoretical maximum output frequency
is 39kHz i.e 10 times better - this is still only for a 16 step
waveform so not as good as it sounds!
If you really want high speed output you need a dedicated DDS such as an AD9833 (this is not a DAC though and generates single sine waves).
Another alternative is to use a parallel DAC such as the 8bit DAC
from Analogue Devices DAC08. With that one you can write 8 bits on a parallel
bus so its fast (updating within 85ns). Speed = 1.0/(512 * 85e-9) = 22.9kHz (if you can drive it that fast!).