I'm using ESP-IDF 5.3 to connect with an MCP4716 through I2C.
If I use the i2c tools example I'm able to see the device with address 0x60. I'm trying to build the command link to write to this register but I'm way lost on how to do it.
How to ESP-IDF I2C with MCP4716
How to ESP-IDF I2C with MCP4716
- Attachments
-
- Screenshot 2024-11-05 161025.png (176.51 KiB) Viewed 702 times
-
- Posts: 1733
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: How to ESP-IDF I2C with MCP4716
Are you using the 'legacy' I2C driver ("i2c.h") or the new one ("i2c_master.h")?
With the new one, you don't have to deal with "cmd links" in this case; you can just use i2c_master_transmit(), like
With the new one, you don't have to deal with "cmd links" in this case; you can just use i2c_master_transmit(), like
Code: Select all
uint8_t data[2]; // Holds the two bytes to send. data[0] is transmitted first, then data[1]
data[0] = (<power down bits> << 4)| <data bits d09...d06>;
data[1] = (<data bits d05...d00> << 2);
esp_err_t result = i2c_master_transmit(devhdl, data, 2, portMAX_DELAY); // Send the two bytes from data to the I2C slave
Re: How to ESP-IDF I2C with MCP4716
I'm indeed using i2c_master.h but I think my right/left shift codes were bad and the DAC wasn't being updated.
I will try your solution
I will try your solution
Who is online
Users browsing this forum: Google [Bot] and 79 guests