Interface with Temp Sensor, SMBus Protocols

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
joli_601446
Level 5
Level 5
10 likes given 10 sign-ins 5 sign-ins

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?

Thanks,

Joe

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

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) ;

RECEIVE-BYTE FORMAT

data = i2c_ReadByte() ;

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

moto

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

View solution in original post

0 Likes
4 Replies
joli_601446
Level 5
Level 5
10 likes given 10 sign-ins 5 sign-ins

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.

0 Likes

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.

MasterWrite_MasterRead.jpg

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.

MasterWrite.jpg

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

MasterRead.bmp

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?

Thanks,

Joe

0 Likes

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

I2C_MasterRead.jpg

lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

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) ;

RECEIVE-BYTE FORMAT

data = i2c_ReadByte() ;

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

moto

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

0 Likes