8 Replies Latest reply on Dec 7, 2015 3:34 AM by sarunas.straigis_1530751

    I2C master trouble



      I started exploring the world of PSoC with PSOC 4 BLE kit and it was great until I ran into trouble making i2c bus work.

      I am trying to hook up i2c character LCD, however it seems like I am unable to initialize i2c properly. 

      I tried different pins/speeds, using low level i2c api and high level - nothing helps.

      I check the SCL pin with oscilloscope and don't see any signal. 

      I tried example projects - still no signal on SCL and SDA.. 

      I attach my code and project:


      #include <project.h>
      #include "LiquidCrystal_I2C.h"


      __IO uint32_t TimingDelay = 0;
      uint32_t DeviceAddr = 78;
      uint16 shit=0;
      int i=0;
       int main(void)




              I2C_M_I2CMasterWriteBuf(DeviceAddr, (uint8 *)DeviceAddr, 1, 0);

        • 1. Re: I2C master trouble

          Welcome in the forum, Sarunas.


          I would suggest you to use P5_0 and P5_1 for I2C, the required pullup resistors are already provided on the board and the FRam is on the same bus


          Your first access to the I2C interface must fail:


          I2C_M_I2CMasterWriteBuf(DeviceAddr, (uint8 *)DeviceAddr, 1, 0);


          When the device address of the I2C-LCD really is 0x78 you are trying to submit a databyte from the address of 0x78 which is from flash, Probably not what you want.


          You did not provide a link to the LCD's datasheet, so I cannot check what you have to send.


          The following WriteByte() function will fail because you did not issue a Start() condition.


          The next SendStart() is not followed by a SendStop()


          All I2C-APIs return a status indicating success or failure. Best is to check that.


          For both the APIs SendStart() and WriteBuf() the last parameter has a meaningful #define (to be found in the .h-file), better to use that, makes it clear what you want to do.





          • 2. Re: I2C master trouble
                    thank you for your suggestions. I probably did not make myself clear. shouldnt there be a signal in SCL even though the data is not being transmitted? I am not initializing lcd yet, just checking if I get a signal on I2c and any combination seems not to be working...   
            • 3. Re: I2C master trouble

              Sarunas: Well I have look over your program and I think there is a few issue with it. The I2C pins are P3-4 and P3-5 these are set for the Arduino I2C output pins on the Pioneer board J3. Also you need to have pullup resistors on these pins.  Also I have no ideal what I2C LCD display you are using. So I can't check your address and commands. Also if you look at the PSOC Ble  example program they have both an I2C device and also an I2C LCD device in their program.  There is also a I2C test program in the examples that should help also.

              • 4. Re: I2C master trouble

                You will not see a signal without pullups.





                • 5. Re: I2C master trouble

                  Thanks! I will try your suggestions :) i think i tried all allowed ports already, but will do it again.

                  UPDATE: I managed to see the signal. The problem was indeed passing an argument to I2C_MASTERWRITEBUFFER. I tried sending the pointer of the variable, while it wants an array :)

                  P.S. Are there pins on the pioneer baseboard to which pins 5.0 and 5.1 are connected? Can't find anything in documentation.. also doesn't seem to be on the board.

                  • 6. Re: I2C master trouble

                    You find documentation and schematics for all the kits you successfully installed under Programs(x86)\Cypress\,,,\Hardware


                    The port5 pins fur I2C are on header J10 pins 12 and 14





                    • 7. Re: I2C master trouble

                      I got it working on other pins. Thanks for your help. It turns out, that address had to be shifted by one bit (compared to stm32 i2c configuration). 

                      • 8. Re: I2C master trouble



                        Happy coding