I am attempting to write a basic I2C program using Zephyr, but I am currently unable to sent a single byte over I2C. Am I doing something wrong? I'd prefer not to use the nrfxlib.
Here is a list of the presently known TWIM errata:
(https://infocenter.nordicsemi.com/topic/errata_nRF5340_EngA/ERR/nRF5340/EngineeringA/latest/err_340_new.html)
[21] TWIM: 1000 kbps baud rate is not functional
[37] TWIM: First clock pulse after clock stretching may be too long or too short
[47] TWIM: I2C timing spec is violated at 400 kHz
[82] TWIM: TWIM2 and TWIM3 are not functional
Platform: nRF5340 PDK
SDA: P0.30
SCL: P0.31
Project Configuration:
CONFIG_NEWLIB_LIBC=y CONFIG_PRINTK=y CONFIG_HAS_SEGGER_RTT=y CONFIG_USE_SEGGER_RTT=y CONFIG_RTT_CONSOLE=y CONFIG_UART_CONSOLE=n # nRF5340 board config CONFIG_TRUSTED_EXECUTION_SECURE=y CONFIG_BT=n CONFIG_TIMESLICING=n CONFIG_DEVICE_POWER_MANAGEMENT=y CONFIG_SYS_POWER_MANAGEMENT=y CONFIG_SYS_POWER_DEEP_SLEEP_STATES=y CONFIG_DEVICE_POWER_MANAGEMENT=y CONFIG_I2C=y CONFIG_I2C_1=y
main.c
#include <zephyr.h> #include <device.h> #include <sys/printk.h> #include <drivers/i2c.h> /* Application main Thread */ int main(void) { struct device *p_i2c = device_get_binding("I2C_1"); u32_t dev_config = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_MASTER; int res = i2c_configure(p_i2c, dev_config); if (res) { return res; } u8_t buf[2] = {0x0, 0xFF}; i2c_burst_write(p_i2c, 0x77, 0x14, buf, 2); return 0; }
Waveform: