1 2 Previous Next 27 Replies Latest reply on May 17, 2011 4:11 AM by udayan.umapathi

    I2C

    vishnu.kumar

      Hi this is vishnu.

         

      i am trying to interface temperature sensor MLX90614. before doing this i have inerfaced 24c56 with PSoC sucessfully.

         

      but when i  am trying to interface with this itemperature sensor it is taking 9-10 startup p[ulses to get  ACK (acknowledgement)

         

      after that i am sending (0x07 which is a RAM adress of sensor ) here i am not getting ACK agian we need to send startup signal because of this it is keep on  in that loop only.

         

      i've thought there might be problem with I2C clock .

         

      how we can fix this?

         

      and even how we can get desired clodk for I2C?

         

      i amattaching my project and datasheet of sensor

         

       

         

      Thanking you

         

      V.Vishnu kumar

        • 1. Re: I2C
          vishnu.kumar

          sorry file not uploaded

          • 2. Re: I2C
            graa

            The below code is not correct.  What you are doing is calling the bWriteBytes function again and again till the WR_COMPLETE flag is set.

            while (!(I2CHW_bReadI2CStatus() & I2CHW_WR_COMPLETE))
            {
               I2CHW_bWriteBytes(0x00, (char*)&ReadAddress, 2, I2CHW_CompleteXfer);   
               while(!(I2CHW_fSendStart(0x00, I2CHW_WRITE)))
               {
                  I2CHW_SendStop();        // Send stop to terminate the previous interaction
               }
            }

            Inside the same loop, SendStop is being called as well.  This will totally mess up the transactions and will never let the Write transaction to complete.

            Let me know what transaction you are trying to do with the sensor (reading from a particular location or writing to a particular location) and I will provide you with the code snippet.

            Best Regards,
            Ganesh
            The PSoC Hacker

            • 3. Re: I2C
              vishnu.kumar

              Hi sir thanks for the reply.

                 

                              Sir i  am trying to read temperature value which is available in RAM adress 0x07. now here i am including new modified c file and application note of the sensor. In this application note in page no 16 they provided a flowchart according that now i've written code. in this i am not getting any acknowledgement the sensor. Master device (PSoC) continuosly sending start signal.

                 

                          how we can change the I2C clock?

                 

               

                 

              Thanks and regards

                 

              V.Vishnu Kumar
               

              • 4. Re: I2C
                graa

                I think there is no need to follow the flow chart as it is.  There should be no problem with the Slave sending an ACK to the Master's transactions.  So, you can use the high level APIs bWriteBytes and fReadBytes to write the command and read the temperature from the sensor.  I have modified the project to write a command 0x07 and read 3 bytes of data from the slave.  See if this works.  Try to understand how the high level APIs are used.  That will help you to implement other read/write operations with the slave successfully.

                   

                 

                   

                Best Regards,

                   

                Ganesh

                   

                The PSoC Hacker

                • 5. Re: I2C
                  vishnu.kumar

                  hi sir

                     

                  i've tested that code but i am not getting any thing. it is wending write signal and it is stoping. here i am including the output waveform which is obtained.

                     

                   

                     

                  Thanks & Regards

                     

                  V.Vishnu kumar 

                  • 6. Re: I2C
                    udayan.umapathi
                        
                           
                    • MLX90614 uses SMBus instead of I2C interface. Please note that there are certain differences between I2C and SM Bus operation. I have successfully interfaced MLX90614 with PSoC3 using I2C module.
                    •      
                    • This sensor can give output in PWM form as well as SM Bus. The MLX90614’s SMBus needs a request to switch from PWM to SM Bus(By default on power up sensor gives PWM output). SMBus request condition requires forcing LOW the SCL pin for period longer than the request time 2 milli seconds . The Data line value is ignored in this case.
                    •      
                    • Once disabled  PWM,  it  can  be  only  enabled  by  switching  Off-On  of  the  supply  or  exit  from  Sleep Mode.  
                    •     
                       
                    • 7. Re: I2C
                      graa

                      Without the hardware, it is very difficult to guess what the problem could be.  But I am sure you have to use the logic similar to the one I have used in the program.  Do some other debugging.  Check if the pull up resistors are fine on the SDA and SCL lines.  Try calling the fSendStart and SendStop functions continuously and check with the logic analyzier if the slave ever acknowledges the address.  If it does not, then there should be some other problem.

                         

                       

                         

                      Best Regards,

                         

                      Ganesh

                         

                      The PSoC Hacker

                      • 8. Re: I2C
                        vishnu.kumar

                        hi .

                           

                        i've interfaced same sensor with "MBED nxp LPC 1768" sucessfully. but coming to PSoC i am not getting the acknowledgement. even with MBED board also i am getting perfect output at 20khz I2C frequency only . if i chnaged the frequcny i am not getting the acknowledgment there. thats why i am trying to know how to change the I2C clock in PSoC.

                           

                        here i am including MBED code also.

                           

                         

                           

                        Thanks and Regards

                           

                        V.Vishnu Kumar

                        • 9. Re: I2C
                          vishnu.kumar

                          sorry file uploaded is different here is the right one

                             

                           

                             

                          thanks

                             

                          V.Vishnu Kumar

                          • 10. Re: I2C
                            graa

                            There is a parameter called I2C Clock in the I2CHW settings.  You can select 50KHz for I2C clock and try.  Also, first use only the fSendStart function repeatedly and see if you are getting an ACK from the slave.  Remove all other code and use the below code.

                               

                            while(!(I2CHW_fSendStart(0x00, I2CHW_WRITE)))
                            {
                                I2CHW_SendStop();        // Send stop to terminate the previous interaction
                            }
                             

                               

                            The above code will keep loopin till the slave issues an ACK.  Analyze this with the logic analyzer and let me know if you get an ACK at all.

                               

                             

                               

                            Best Regards,

                               

                            Ganesh

                               

                            The PSoC Hacker

                            • 11. Re: I2C
                              vishnu.kumar

                              hi i've tried those settings which are available 50,100, 400 but no use.

                                 

                              the code line which you sent i've tried that this before , i am getting acknowledgment after 9 write operations (some  times).

                                 

                              is any other way to get custom clocl for I2C?

                                 

                               

                                 

                               

                                 

                               

                                 

                               

                                 

                              Thanks & Regards

                                 

                              V.Vishnu kumar

                              • 12. Re: I2C
                                vishnu.kumar

                                hi Mr. U2

                                   

                                  Can i get the details of your code which is developed on PSoC3. it might be useful for me to implement on PSoC1.

                                • 13. Re: I2C
                                  udayan.umapathi

                                  Please find attached the project that works on PSoC3 device with MLX90614. You might want to use PSoC Creator software to view the same. For your benefit i have attached the "main.c" file separately.

                                     

                                  Please note that i was facing the issue that you are facing, that is no ACK from Slave(MLX sensor). I held the SDA line low for about 10ms and then started issuing I2C commands, it started working. You need this pulse to enter SMBUS operation.

                                  • 14. Re: I2C
                                    udayan.umapathi

                                    Project is attached now.

                                    1 2 Previous Next