Multiple I2C Addresses in PSoC1

Version 1
    Question: How can I implement multiple I²C addresses (multiple slaves) using only one I²C module?



    Solution 1: You can achieve this by modifying the Slave API. You can modify the code where the Address received in I2C_DR is compared with the address of the Slave. From here the program branches to different parts where buffers are written, buffers are read etc. You can have some logic so that depending on the address received, buffers for the respective slaves are accessed. You should also have different variables for the Write Buffer Pointer, Read Buffer pointer, Write Count, Read Count, Read Buffer, Write Buffer etc.

    Solution 2: One more solution is that inside the I2C ISR, at the address compare stage, just store the Address received in the I2C_DR register in an address variable, and proceed with a Read of Write function if the received address matches either of the 2 addresses. In the main program, when you detect the RD_COMPLETE or WR_COMPLETE flag set, test the value in the address variable. According to the address found in the variable, perform the action expected from the respective Slave device. This method is easier to implement and involves minimum modification to the ISR.