Oct 15, 2017

MCP4725 I2C 12-bit DAC (STM32F103C8T6)

This breakout development board can be bought easily online. The interface is I2C.
For other microcontroller, it's easy to hook up because wire.h library can handle the task of sending the value to DAC. For STM32F103, the example codes doesn't work.
It seems the I2C interface get some error. That's the reason why I don't use I2C interface but I emulate the GPIO.

The code will init the GPIO, then zero the DAC and send increment count from 0 to 4095. The maximum voltage output depends on the VCC, in my case is 3.3V. In many examples on google, the address is before left shifted ie. 0x62 or 0x61 but in my code the address is 0xC4 because directly implemented to I2C interface. This circuit will be useful for 0-20 or 4-20mA project Rev3. Using STM32F103C8T6, 7-segment display, DAC, step up DC/DC and V/I converter, Rev3 will be much easier to do.

You can get the code here. Please tell me that the code works, comment or report bug to silvester.dao(_)gmail.com .

No comments:

Post a Comment

MAX7219 8-digits 7-segment (STM32F103C8T6)

I made MAX7219 for C51 but now I need it for STM32F103 too. The wiring is simple: MAX7219_CLK   hooked up to PORTA0, MAX7219_...