Faruk Chaudhry

HCS08QG8 - IIC Read - Codewarrior Simulation

Discussion created by Faruk Chaudhry on May 31, 2010
Latest reply on Jun 3, 2010 by Maike Steil

Hello all,

 

I searched the 8 bit and 8 bit Codewarrior forums, but did find a similar post.

 

Currently, I am working on a test program to read al byte from the Microchip 23008 port expander.  No actual use of data, but only a test.  I have USB oscilloscope on order to see the IIC bus.  In the mean time, I am using the Codewarrior simulator to view the IIC bus transfer.  See the code below.  My question relates to the second byte received.  Is there actually a second byte received ?

 

Thanks

 

void DISPReadBarGraphData(void)
{
 
  unsigned char dout;
  unsigned char acknowledge;
 
  SEND_START_BIT;         // send start signal
  IICD = DISP_MCP_1_SL_ADDR;   // send MCP control byte (R\W bit preset to 0)
  while(!IICS_IICIF);     // wait for byte transfer to complete
  IICS_IICIF = 0;
  acknowledge = check_ACK();
  if (acknowledge == DEVICE_NO_ACK)
    return;
  IICD = DISP_OLAT;       // send MCP OLAT register address
  while(!IICS_IICIF);     // wait for byte transfer to complete
  IICS_IICIF = 0;
  acknowledge = check_ACK();
  if (acknowledge == DEVICE_NO_ACK)
    return;
  SEND_RPSTART_BIT;       // send repeat start bit
  IICD = DISP_MCP_1_SL_ADDR | 0x01;    // send MCP control byte (R\W bit set to 1        
  while(!IICS_IICIF); // wait for byte transfer to complete
  IICS_IICIF = 0;
  acknowledge = check_ACK();
  if (acknowledge == DEVICE_NO_ACK)
    return;
  IIC_RX_MODE;            // set IIC for recieve mode
  IICC_TXAK = 1;      // no ACK sent to slave
  dout = IICD;        // dummy read to clock byte in
  while(!IICS_IICIF); // wait for byte transfer to complete
  IICS_IICIF = 0;
  SEND_STOP_BIT;
  dout = IICD;
  DISPGraphContent = dout;
  }

Outcomes