6 Replies Latest reply on Aug 7, 2018 12:26 AM by lola_1681776

    Hi to the forum

      I have a trouble using PSoC 5lp with the sensor AS7262. I am trying to interface it with I2C protocol but I am stuck both in reading and in writing register to the AS7262 slave.

      The HW seems ok, the sensor is working because i have tested with an arduino. I am getting this error from status = I2C_MasterStatus();

      status = I2C_MSTAT_ERR_ADDR_NAK

      What exactly does it mean ?

      I can upload the project ( just the function to read and write register to / from the sensor) and the specification of the sensor.

      Thank you !!


        • 1. Re: Hi to the forum

          Probably an addressing error. You need a 7-bit address for your AS7262 which is 0x49 (see datasheet). The read/write bit gets automatically appended by the I2C component.



          • 2. Re: Hi to the forum

            Thank you Bob for the quick response !

            I know I am doing something "basic" wrong but I do not know what ...

            I am using a freeScC2 board and SCL = 6.1 SDA = 6.0. The sensor is connected to a shield with a level translator 5 -> 3,3 V. I checked the signals and they seems good. I used the same shield + sensor with an arduino and all was fine so I can infer that the shield + sensor are ok.


            When I send a start I obtain I2C_MSTR_ERR_LB_NAK

            result = I2C_MasterSendStart(0x49,WRITE);

            When I send a restart I obtain I2C_MSTR_NOT_READY

            result = I2C_MasterSendRestart(0x49,WRITE);


            If I disconnect the sensor the results are the same so it must be an addressing problem or an hw problem but the address is correct (0x49) and the HW is working.

            Maybe I should try with another PSoC 5lp board, do you think I can avoid the 5 - 3,3 V translator between PSoC and sensor ?


            Thank you

            Lodovico from Italy

            • 3. Re: Hi to the forum

              Can you please post your complete project so that we all can have a look at all of your settings. To do so, use

              Creator->File->Create Workspace Bundle (minimal)

              and attach the resulting file.

              I do not know the freesoc board, Are the I2C signals pulled up? How many ohms??


              The 5V to3.3V level shifter might be required when the freesoc board runs at 5V.

              A simple level shift will not work because of the signal kind: both the lines SDA and SCL are pulled up and can be driven low by master or any slave.



              • 4. Re: Hi to the forum


                attached is the zip file of the project. The project is still a "work in progress" ...

                the sensor (I2C slave) has its 4.7k pull-up resistor. I am using a bi-directional level shifter with other 4.7k pull-up resistor in both the sides (HV and LV).

                Maybe also the master side needs the pull-up resistor, but there are the ones of the shifter.

                In the next days I will try with the final CY8CKIT-059 (freesoc is for the test but it should work), and, last chance I can use UART interface with the same sensor .

                Thank you Bob !


                • 5. Re: Hi to the forum

                  result = I2C_MasterSendStart(0x49,WRITE);


                  This line will make the I2C bus busy, a second call (even after a reset) might fail.

                  For testing purposes only: terminate the occupied bus with a I2C_MasterSendStop() API.



                  • 6. Re: Hi to the forum


                    I changed the level shifter and now it seems it works, at least with the simple tests I did. I hope the problem is solved.

                    Thank you for making me think about the level shifter !