This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simulating an I2C master

I am developing an application that functions as an I2C slave. To test it, I am trying to write a debug function to simulate the I2C master. With what I have so far, I successfully start I2C communication and receive the first byte. However, after that, the I2C interrupts stop triggering in my application, and the debug function never receives any more bytes.

It seems like the ACK from the master never registers in the application.
Here's my debug function:

signal void ReadI2CData()
{
   printf("Sent: Read request to address 0x28\r\n");
   I2C1_IN = 0x0100; //Initiate transfer
   I2C1_IN = 0x28 | 0x01; //from the address of the slave

   wwatch(I2C1_OUT); // Wait for data from Microcontroller

   if ( I2C1_OUT == 0xFF00 ) //Slave sent an ACK
   {  printf("Received: ACK\r\n"); }
   else
   {  printf("Received: %d!\r\n"); return; }


   while (1)
   {
      wwatch(I2C1_OUT); //Wait for data from Microcontroller
      printf("Received: %d\r\n", I2C1_OUT);
      I2C1_IN = 0xFF00; //Send the ACK! (This doesn't trigger the interrupt in the application)
   }
}

Any thoughts would be appreciated. Thanks.