2 Replies Latest reply on Apr 18, 2018 8:55 PM by BeS._284136

    Best Way To Transmit ADC Data Over I2C




      I have two circuit boards. One contains a PSOC4 CY8C4245PVI-482. The other contains a CY8C5868AXI-LP035 PSOC5.


      The PSOC4 board monitors 12 analog sensors with the SAR. The results are converted into floating point voltage values. I have this part is working. Also, I am using a union to represent the 4 byte float as a uint8 array with 4 locations, so getting the bytes for transmission is no problem.


      I need to transmit the bytes from the PSOC4 to the PSOC5 for further processing. I have the infrastructure setup in my system to use I2C for this purpose, as I am using other I2C devices.


      The master is on the PSOC5 board. The slave is the PSOC4 (address 0x0A). So far, I can talk I2C from the PSOC5 board to the PSOC4 board but am having trouble having the slave talk back to the master. I have a suspicion I am not utilizing the I2C object in the most optimal way, as I have not used I2C on a PSOC yet. I have the I2C code posted for both the master and the slave.


      Can anyone offer any suggestions to most effectively write the bytes back to the master? I have the project for the PSOC4 attached. The master code is too involved to post here, so I attached only the I2C header and code files.

        • 1. Re: Best Way To Transmit ADC Data Over I2C

          Hi Ben,


          You can refer to the code example in Psoc Creator : SCB_I2cCommSlave .




          • 2. Re: Best Way To Transmit ADC Data Over I2C

            I did manage to get my slave to communicate back to the master. In the process, I discovered a new problem:


            Since my PSOC4 slave spends most of its time capturing and processing information off the A to D sensors, some commands I issue from the master do not get through to the slave. This mainly occurs when I send two commands sequentially from the master.


            This happens because I have my program listening for commands then updating the sensors (or taking CPU time to execute the command). When the second command reaches the slave, the slave PSOC4 is busy and therefore cannot execute it.


            What would be very helpful is if I had an interrupt that fires on a valid address receipt. Upon arrival of the address, I would invoke the command sent in the I2C data stream.


            I do know that the I2C object has an interrupt, but this manages the transfer of data. I may be wrong, but the interrupt does not seem capable of performing what I need.


            Is there a way of tapping into the interrupt or do I have to rely on polling? Is there a way, perhaps I can signal that the slave is busy? Any other suggestions you folks have?