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.
I tried being the master and writing to the simulated slave (http://www.keil.com/support/docs/3325.htm) and again it sends the first byte and then it gets stuck. "I2C1_IN = 0xFF00;" seems like it doesn't register.
Is there another way to test my I2C implementation before hooking up the actual hardware?
Thanks.