MAX5842
Quad, 12-Bit, Low-Power, 2-Wire, Serial Voltage-Output DAC
Development Log
Chris did some Ninja soldering:
Looked up details in the the datasheet:
- Interface is I2C compatible, up to 400KHz
- 2.7-5.5v
So all looks fine for normal connection to mbed
+--------+
ADD -| 1 10 |- OUTD
SCL -| 2 9 |- OUTC
VDD -| 3 8 |- OUTB
GND -| 4 7 |- OUTA
SDA -| 5 6 |- REF
+--------+
MAX5842 Pinout
Non-obvious pins and things picked out of description:
- ADD - sets the address LSB (will set to 0v)
- REF - the voltage the output is a proportion of (will set to 3.3v)
- VOUT = (VREF * value)/4095
- Following power-up, a wake-up command must be initiated before any conversions are performed
- The MAX5842 SDA and SCL drivers are open-drain outputs, requiring a pullup resistor to generate a logic high voltage
Addresses:
+-------------------+
MAX5842L | 011110 | ADD | RW |
MAX5842M | 101110 | ADD | RW |
+-------------------+
Text is very small, but I think I've got an L.
For writes, bits C3-C0 configure and bits D11-D0 are DAC data. Also an extended set for controlling power
+--------------+ +--------------+ | C3-0 | D11-8 | | D7-0 | +--------------+ +--------------+ +--------------+ +-----------------+ | 1111 | 0000 | | xx DCBA PD1 PD0 | +--------------+ +-----------------+
Write a simple sanity program to dump out the value of an AnalogIn pin, which is connected to the output A of the MAX part.
#include "mbed.h"
AnalogIn res(p16);
DigitalOut myled(LED1);
int main() {
while(1) {
printf("res = %f\n", res.read());
myled = !myled;
wait(0.25);
}
}
works :)
Ok, lets try wiring and write something...
Schematic
---+--+--- 3.3v
| | |
# # # pull-up resistors for I2C
# # +--------+ # I used ~1k, just because that is what was around
0v --|--|-- ADD -| 1 10 |- OUTD |
p10 -o--|-- SCL -| 2 9 |- OUTC
3.3v ---|-- VDD -| 3 8 |- OUTB
0v -----|-- GND -| 4 7 |- OUTA ---- p16
p9 -----o-- SDA -| 5 6 |- REF ----- 3.3v
+--------+
#include "mbed.h"
AnalogIn res(p16);
DigitalOut myled(LED1);
I2C max5842(p9, p10);
int main() {
// ADDR: 011 110 ADD, ADD = 0
// 011 1100 == 0x3C
int addr = 0x3C;
char data[2] = {0x08, 0xF0};
max5842.write(addr, data, 2);
while(1) {
printf("res = %f\n", res.read());
myled = !myled;
wait(0.25);
}
}
No error, so know address is right, as if change it I2C fails.
AnalogIn is 0, so need to perhaps now do powerup sequence:
// Power up the DAC
// - Extended Commands [ 1111 0000 xx DCBA PD1 PD0 ]
// - DCBA = 1111 means select all, PD = 00 means power on
char power_up[2] = {0xF0, 0x3C};
max5842.write(addr, power_up, 2);
Yep! It is alive!
Resulting test program:
Attachments
- MAX5842.jpg (39.3 kB) - added by simon.ford@… 6 months ago.

