PIC24E I2C communication with MCP4725

Running the Experiment

We make a simple program flow, using the ADC readouts from our previous article Simultaneous Sampling of 4 ADC Channels with PIC24E. Only the value from AN0 is sent to the MCP4725. The 12-bit DAC value is created by shifting left twice the 10-bit value from AN0.


For example, maximum read of AN0 = 1023 converts to DAC value of 4095. This translates to voltage equal to Vdd of MCP4725, or 3.3 volts.

Even though the ADC readout from AN0 never exceeds 1023 in this experiment, It is a good practice to limit the DAC value to the 12-bit range

 ODCBbits.ODCB8=0;  // ASCL1
 ODCBbits.ODCB9=0;  // ASDA1

Figure 2 – 4 show readouts from a voltmeter with 3 values of AN0. The voltage output equal 3.3, 2.14, and 0.36 volts when AN0 read 1023, 658, and 111, respectively. Simple calculations verify they are correct. For, example, for AN0 = 111, the output must equal (111 x 3.3)/1023 = 0.358 volt.

Figure 2 DAC voltage readout (3.3 Volts) when AN0 = 1023

Figure 3 DAC readout (2.14 Volts) when AN0 = 658

Figure 4 DAC readout (0.36 volt) when AN0 = 111


  1. R. Reese, J.W. Bruce and B.A. Jones, Microcontrollers: From Assembly Language to C Using the PIC24 Family, Cengage Learning, 2009.



Comments are closed.