Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
@Middleware & OS Gm guy’s, I’m trying to interface an EEPROM with my AVR microcontroller using Zephyr RTOS. I’ve configured the I2C peripheral in the `prj.conf` file and set up the device tree bindings. However, when I attempt to write data to the EEPROM, I get an I2C transaction error. I have been able to configured the I2C peripheral in `prj.conf`. Created device bindings in the device tree source file (`dts`). and salso wrote an application to write data to the EEPROM.
this is my code snippet:
#include <zephyr.h>
#include <device.h>
#include <drivers/i2c.h>
#include <logging/log.h>
LOG_MODULE_REGISTER(main);
#define EEPROM_I2C DT_NODELABEL(eeprom)
void main(void) {
const struct device *i2c_dev = DEVICE_DT_GET(EEPROM_I2C);
if (!device_is_ready(i2c_dev)) {
LOG_ERR("I2C device not ready");
return;
}
uint8_t data[2] = {0x00, 0xFF}; // Address and data to write
int ret = i2c_write(i2c_dev, data, sizeof(data), EEPROM_ADDR);
if (ret) {
LOG_ERR("I2C write failed: %d", ret);
return;
}
LOG_INF("Data written to EEPROM");
}
Despite configuring everything, the I2C write operation fails. What could be causing this error?
CONTRIBUTE TO THIS THREAD