cancel
Showing results for 
Search instead for 
Did you mean: 

Code Examples

joli_601446
Contributor

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
MotooTanaka
Esteemed Contributor

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