4 Replies Latest reply on Oct 30, 2018 7:11 AM by joli_601446

    Interface with Temp Sensor, SMBus Protocols


      Hello, I'm interfacing a PSoc5 MCU with a MAX6581 Temperature Sensor. The Sensor has a SMBUS/I2C Compatible interface. I'm using I2C Master module to interface with the device. I have been playing with a PSoc5 Dev Kit to learn how I2C works. The problem I see is that I don't see the I2C Read/Write on the Dev Kit match the datasheet page 10 and 11. I've attached pages 10 and 11 for anyone to look over and maybe see if it is even possible to implement an I2C link with this temperature sensor.


      When I look at the I2C traffic is a logic analyzer and say I'm doing an I2C_MasterReadByte I only see the address followed by the Bytes I'm reading.


      Can anyone help me please?




        • 1. Re: Interface with Temp Sensor, SMBus Protocols

          I'm looking more into these SMBus Protocols and I'm beginning to think that it is not supported in PSOC Creator. I hope I'm wrong.

          • 2. Re: Interface with Temp Sensor, SMBus Protocols

            Hello, I went back and looked at an I2C MasterRead example that I did a few days ago and looked at the I2C signals and I believe things working correctly.



            This shows the MasterWrite command first that passes the Device Address and the "Command" or "Sub-address". The second group is a MasterRead. The time between the MasterWrite and MasterRead is about 3.038ms.



            Here is the MasterWrite passing the Device Address and the "Command" word. I use the "Command" to match the SMBus protocol wording.



            Here is the MasterRead. What bothers me is the 3.03msec between the two functions. I thought it would be back to back transactions.


            Does this look okay?




            • 3. Re: Interface with Temp Sensor, SMBus Protocols



              Although I don't have 5LP, from PSoC Creator Project, HAL drivers generated

              seem to be similar with PSoC 4, so I'm hoping that my strategy also works for you.


              First of all to support the protocol written in the datasheet,

              usually no "single" command do it all,

              so we need to use multiple HAL APIs to fulfill the format.


              For example, where 'S' is written  use I2C_MasterSenStart()

              and where 'P' is written use I2C_MasterSendStop()

              for the COMMAND use I2C_MasterWriteByte()

              for the DATA user I2C_MasterReadByte().


              Apparently, this is somewhat bothersome, so I created my intermediate API interface(s)

              and using them. (i2c_utils.h and i2c_utils.c)


              With these, after I2C_Start(), you can

              WRITE-BYTE FORMAT

              i2c_writeReg(command, data) ;


              READ-BYTE FORMAT

              data = i2c_readReg(command) ;


              SEND-BYTE FORMAT

              i2c_WriteByte(data) ;



              data = i2c_ReadByte() ;


              NOTE: this may not work for your system, but at least it can be some hints for you, I hope.



              P.S. OOPS, I took too long, before I wrote you have found the solution, congrats!

              • 4. Re: Interface with Temp Sensor, SMBus Protocols

                I found my error in the code. I had a 3msec delay, removed the delay and things look much, much better.