i2c on relex kit

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

cross mob
User19171
Level 1
Level 1
Hi all, I am new and use the XMC for two weeks and have an issue with the i2c master app/code.

I use an MPU 6050 (Gyro-Sensor) and the i2c doesn't work. I checked with the oscilloscope and anytime the XMC send the address and the register bits.
I use DAVE4 and the original i2c code (i2c_master) and also the Infineon i2c example.


#include

void delay_count(uint32_t);

uint32_t delay_cycles = 0;
#define ONESEC 1000000U

#define SLAVE_ADDRESS 0x68
#define BYTES_TO_READ 16
#define BYTES_TO_TRANSMIT 16

typedef enum PCA9502_REGADDR {
IO_DIR = 0xA << 3,
IO_STATE = 0xB << 3,
IO_INTE = 0xC << 3,
IO_CTRL = 0xE << 3
} PCA9502_REGADDR_t;

uint8_t mem_address[2];
uint8_t data = 0x3B;
uint8_t data2 = 0x3D;
uint8_t tx_buffer[64] = {0x3B,0x3D,0x3F,0x41,0x43,0x45,0x47};
uint8_t rx_data;

int main(void)
{
DAVE_Init();

mem_address[0] = IO_STATE;
I2C_MASTER_Init(&I2C_MASTER_0);

I2C_MASTER_Transmit(&I2C_MASTER_0,true,SLAVE_ADDRESS,mem_address,1,false);
while(!I2C_MASTER_IsTxBusy(&I2C_MASTER_0));

I2C_MASTER_Transmit(&I2C_MASTER_0,false,SLAVE_ADDRESS,tx_buffer,5,true);
while(!I2C_MASTER_IsTxBusy(&I2C_MASTER_0));

I2C_MASTER_Transmit(&I2C_MASTER_0,true,SLAVE_ADDRESS,mem_address,1,false);
while(I2C_MASTER_IsTxBusy(&I2C_MASTER_0));

I2C_MASTER_Receive(&I2C_MASTER_0,true,SLAVE_ADDRESS,&rx_data,1,true,true);
while(I2C_MASTER_IsRxBusy(&I2C_MASTER_0));

while(1U)
{
delay_count(0xfffff);
DIGITAL_IO_ToggleOutput(&LED_2);
}

return 1U;
}


what is wrong? I hope somebody can help me.
0 Likes
0 Replies