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

3D Hall (Magnetic sensor) Forum Discussions

Michael_K
Level 2
10 replies posted 5 questions asked 10 sign-ins
Level 2

Hello everybody,

I have some problems to communicate with a 2D hall sensor from Infineon via I2C.

First some background information:

CY8CKIT-42 PSoC 4 Pioneer Kit

PSoC Creator 4.4

TLE493D-A2B6 (https://www.infineon.com/dgdl/Infineon-TLE493D-W2B6-UM-v01_01-UserManual-v01_11-EN.pdf?fileId=5546d4...

I wrote myself two functions which allow me to read or write a register.

The TLE493D has a 2-byte read command and a 1-byte read command. So I try to write the register first and change it to 1-byte read command mode.

When I try to write a register, it works, but when I try to read a register, I always get a NACK after I send the register address of the sensor. I don't know what the problem is.

 

I tried the read function with a MPU6050 sensor and it worked. I could read the register.

Why can't I read the registers properly?

I have added some pics and the project in the attachment.

 

Best Regards and Thank You

Michael

0 Likes
1 Solution
jepaz
Level 4
25 replies posted 10 replies posted 10 questions asked
Level 4

Hi,

I think you just need to change your read routine so that it uses the I2C_1_I2C_MODE_COMPLETE_XFER  flag, they are two separate processes that have to be completed acknowledged  separately,

when using this flag I2C_1_I2C_MODE_NO_STOP you would not use the API Write/Read Buffer but work with Bytes instead

 

uint8 tle493d_ReadReg(uint8 Reg)
{
uint8 Write_Buf[1] = {0};
Write_Buf[0] = Reg;

uint8 Read_Buf[1] = {0};

I2C_1_I2CMasterWriteBuf(TLE493_ADDRESS,(uint8 *)Write_Buf,1,I2C_1_I2C_MODE_COMPLETE_XFER  );
while((I2C_1_I2CMasterStatus() & I2C_1_I2C_MSTAT_WR_CMPLT)== 0){}

I2C_1_I2CMasterReadBuf(TLE493_ADDRESS, (uint8 *)Read_Buf,1,I2C_1_I2C_MODE_COMPLETE_XFER  );
while((I2C_1_I2CMasterStatus() & I2C_1_I2C_MSTAT_RD_CMPLT) == 0){}

return Read_Buf[0];
}

 

hope it helps

 

View solution in original post

2 Replies