- Name: MCP4725_PICO
- Description:
Library Driver for MCP4725 DAC modules, for Raspberry pi PICO RP2040.
The MCP4725 is a low-power, high accuracy, single channel, 12-bit buffered voltage output Digital-to- Analog Converter (DAC) with nonvolatile memory (EEPROM). Its on-board precision output amplifier allows it to achieve rail-to-rail analog output swing.
-
Supports MCP4725 features including EEPROM r/w, Power modes and general call.
-
Toolchain
- Raspberry pi PICO RP2040
- SDK C++, compiler G++ for arm-none-eabi
- CMAKE , VScode
There are eight example files. The example files are in example folder. To build the one you want, edit the Cmaketxt file add_executable(${PROJECT_NAME} section, comment in one example file path and one ONLY.
Path Name | Function |
---|---|
isConnected | Check I2C connection continuously, useful for debugging I2C bus issues |
demoTest | Carries out Test on various features, EEPROM, power mode's etc |
setVoltage | Carries out Tests on voltage and input code methods |
squareWave | Generates a square waveform 100 Hz |
triangleWave | Generates a triangle waveform 75 Hz |
sawToothWave | Generates a saw tooth waveform 150 Hz |
sineWave | Generates a sinusoidal waveform at various values, see file header |
random | Random data generation |
The example files output Data to the PC serial port using printf, default settings.(baud rate 38400).
API
The API (application programming interface) documentation is at link hosted on github pages and generated by Doxygen.
Set Voltage Input code
The user can set the Voltage output using a voltage or an input code. The input code is calculated using following. Example ::
- Required voltage output of 1.65 V
- Voltage reference of 3.3 Volts
- DAC resolution of 2^12 (4096)
- The Din or input code would be 2048.
EEPROM
The Device can store a voltage output value and power mode status in its onboard EEPROM. In the event of a software reset or power loss, The device will read EEPROM and restore these settings. If the power supply voltage is less than the POR(Power-On-Reset) thresh- old (VPOR = 2V, typical), all circuits are disabled and there will be no DAC output. . When Vdd increases above Vpor device "resets" and gets data from EEPROM(stored voltage and power on conditions).
Power modes
The device has 4 modes. Normal and 3 power down modes. During the power-down mode, the device draws about 60 nA (typical).
General call method
The general call address (0x00) is for addressing every device connected to the I2C-bus at the same time. This command may potentially cause issues with other slave devices on the I2C bus. The MCP4725 has two possible arguments here , Reset and wakeup. Reset is a software reset and will result in EEPROM values being set. Wakeup is to exit a power down mode and return to normal.
Pinout
Pin | Function |
---|---|
OUT | Analog Voltage output of DAC |
GND | Ground Reference |
SDA | Digital I/O Serial data. Transmits and receives data |
SCL | Digital input Serial clock input. Clocks data on SDA |
GND | Ground |
VDD | Reference + supply voltage 2.7v - 5.5v, In PICO case connect to 3.3v |
A0 | I2C Address Bit Selection pin (A0 bit)^^ |
^^This pin can be tied to VSS or VDD, or can be actively driven by the digital logic levels. The logic state of this pin determines what the A0 bit of the I2C address bits should be. The address is also effected by which variant of chip. There are 3 variant's thus 6 choice's of I2C address
The module tested has 2 X 4.7 kOhm pull up resistors on I2C bus and a bypass capacitor. An additional 10 µF capacitor (tantalum) in parallel is also recommended to further attenuate high frequency noise.
Saw tooth waveform.
Sine waveform.