Hi,
thank you for your reply. My confusion came from the "i2c.h" file which talk about pin number starting at one.
Things go better now as there is activity on clock and data signals, but it doesn't work yet. Look at this source code:
#define VOS_DEV_I2C 5
// Configure direction of port B
vos_gpio_set_port_mode(GPIO_PORT_B, 0x0c);
// i2c interface
vos_iomux_define_output(14, IOMUX_OUT_GPIO_PORT_B_2);
vos_iomux_define_output(15, IOMUX_OUT_GPIO_PORT_B_3);
// Needed declarations
i2c_ioctl_cb_t i2c_iocb;
i2c_port_t i2c_port;
unsigned char i2cerr;
char i2c_Buf[8];
uint16 i2c_Nbr;
VOS_HANDLE hI2C;
// Define the I2C pins
i2c_port.clkPort = I2C_PORT_B;
i2c_port.clkPortNo = 3; // Pin 15
i2c_port.dataPort = I2C_PORT_B;
i2c_port.dataPortNo = 2; // Pin 14
i2cerr = i2c_device_init(VOS_DEV_I2C, &i2c_port);
// Open I2C Interface
hI2C = vos_dev_open(VOS_DEV_I2C);
// Set RTC address
i2c_iocb.ioctl_code = VOS_IOCTL_I2C_SET_DEVICE_ADDRESS;
i2c_iocb.data = 0x68;
i2cerr = vos_dev_ioctl(hI2C, &i2c_iocb);
// Set I2C options
i2c_iocb.ioctl_code = VOS_IOCTL_I2C_SET_OPTIONS;
i2c_iocb.data = I2C_OPTIONS_READ_ADDRESS;
i2cerr = vos_dev_ioctl(hI2C, &i2c_iocb);
// Set address to read
i2c_iocb.ioctl_code = VOS_IOCTL_I2C_SET_RDWR_ADDRESS;
i2c_iocb.data = 0x00;
i2cerr = vos_dev_ioctl(hI2C, &i2c_iocb);
// Read one byte form Addess 0x00
i2cerr = vos_dev_read(hI2C, i2c_Buf, 1, &i2c_Nbr);
First: All
vos_dev_ioctl() calls return 1. From what i saw in the disassembly code window, this is normal and each call successfully did its job. But according to the manual, the
vos_dev_ioctl() function should return 0 in case of success.
Second: The
vos_dev_read() fail and return 2. With my scope, i know that the first byte (which contain the start condition,the chip address, the direction bit) is sent to the RTC which response with an ACK. But that is all i see and the R/W bit is set to 0 instead of 1 for a read.
I tried to find where the problem could be in the assembler code, but your debugger doesn't allow to put breakpoint in the assembler code which makes the debug process almost impossible.
Maybe, i do something wrong, but i don't know what.
In attachment, you will find the result of the
vos_dev_read() function.
Can you help me again ?
Thanks.