IIC communication problem with MC56F84763

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IIC communication problem with MC56F84763

540 Views
petercernan
Contributor I

Hello, I'm working on control board with MC56F84763 (I'm using CW10.7 + Quickstart 2.6 to develop the application).

I faced problem with IIC interface. I'm able to write data to PCF8574 I/O Exander using following code (I'm not using ISR, just calling function in main()):

 /* initialize IIC write transaction with PCF8574 - address 0x40 for write */
  while (ioctl(IIC_0, IIC_GET_BUS_BUSY, NULL))
  {
  }
 /* select transmit mode */
  ioctl(IIC_0, IIC_TX_RX_MODE, IIC_TRANSMIT);
  ioctl(IIC_0, IIC_MASTER_SLAVE_MODE, IIC_MASTER);
 /* write I2C address */
 ioctl(IIC_0, IIC_WRITE_DATA, 0x40);
 archDelay(10000);
  while (ioctl(IIC_0, IIC_GET_RX_ACK, NULL))
 {
 }
 /* write data */
 ioctl(IIC_0, IIC_WRITE_DATA, LED_config);
 archDelay(10000); 
  while (ioctl(IIC_0, IIC_GET_RX_ACK, NULL))
  ioctl(IIC_0, IIC_MASTER_SLAVE_MODE, IIC_SLAVE);
I tried to use similar function for IIC read but it does not work:
     while (ioctl(IIC_0, IIC_GET_BUS_BUSY, NULL))
     {
     }
    /* select transmit mode */
     ioctl(IIC_0, IIC_TX_RX_MODE, IIC_TRANSMIT);
     ioctl(IIC_0, IIC_MASTER_SLAVE_MODE, IIC_MASTER);
    /* write I2C address - PCF8574 address 0x41 for port reading */
     IIC_0_write_byte(0x41);
     /* read data from PCF8574T */
      ioctl(IIC_0, IIC_TX_RX_MODE, IIC_RECEIVE);
      archDelay(10000);
     Button_temp_1 = ioctl(IIC_0, IIC_READ_DATA, NULL);

     ioctl(IIC_0, IIC_MASTER_SLAVE_MODE, IIC_SLAVE);
Any idea what's wrong in IIC read function?
Thanks in advance
Peter
0 Kudos
2 Replies

369 Views
petercernan
Contributor I

Hello Xiangjun Rong, thank you very much for your feedback. I was focused to other parts of my application in last days. Let me try your proposal in next two working days. I'll come back. Have a nice day. Peter

0 Kudos

369 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Peter,

i think the reading process has issue.

This is the reading process:

1)set IIC transmit mode and master mode and write slave address with WRITE mode  ioctl(IIC_0, IIC_WRITE_DATA, 0x40);

2)write PCF8574 address 0x41 for port reading as data with code IIC_0_write_byte(0x41);

3)send "repeat start command"

4)rewrite the slave IIC address and set read mode for example  ioctl(IIC_0, IIC_READ_DATA, 0x40);

5)read data normally

/* read data from PCF8574T */
      ioctl(IIC_0, IIC_TX_RX_MODE, IIC_RECEIVE);

Hope it can help you

BR

Xiangjun Rong

0 Kudos