Hi,
Thanks for the response. I am able to send the data in polled mode. But actual data is not sent, event address sent is wrong. Instead of 0x20 something else is sent. Data sending stopped after sending 1 byte , it supposed to send 3 byte
Am I using correct write API. Below is the piece of code
setup_I2C();
_time_delay (1L);
/* Open the I2C driver, and assign a I2C device handler */
fd = fopen ("i2c0:", NULL);
if (fd == NULL)
{
printf ("Failed to open the I2C driver!\n");
_time_delay (200L);
_mqx_exit (1L);
}
/* Set I2C into Master mode */
ioctl (fd, IO_IOCTL_I2C_SET_MASTER_MODE, NULL);
/* Set the destination address */
ioctl (fd, IO_IOCTL_I2C_SET_DESTINATION_ADDRESS, <c_i2c_slave_adr);
_time_delay (1L);
/* Write 2 bytes of data: the desired register and then the data */
result = fwrite (¶m, 1, 3, fd); //data to write, size of unit, # of bytes to write, I2C device handler
// result = write(fd,&val, 2);
fflush (fd);
_time_delay (3L);
if (result == 0)
{
printf ("Write FAILED! with %d\n", result);
}
else
{
printf ("OK - Sent: %d bytes of 0x%08x\n", result, param);
}
//ioctl (fd, IO_IOCTL_FLUSH_OUTPUT, NULL);
//_time_delay (1L);
/* Send out stop */
ioctl (fd, IO_IOCTL_I2C_STOP, NULL);
fclose(fd);
Attached is the snapshot