hi im using lpc1768 to communicate with mpu6050 and i have some problems with i2c protocol and im not sure what it is about. actually i cant send and receive any data.i put my codes below and the first part is setting of i2c and the second part is my code to send data.
* Init I2C pin connect */ PinCfg.OpenDrain = 0; PinCfg.Pinmode = 0; PinCfg.Funcnum = 1; PinCfg.Pinnum = 27; PinCfg.Portnum = 0; PINSEL_ConfigPin(&PinCfg1);//SDA0 PinCfg.Pinnum = 28; PINSEL_ConfigPin(&PinCfg1);//SCL0 // Initialize I2C peripheral I2C_Init(LPC_I2C0, 10000); /* Configure interrupt for I2C in NVIC of ARM core */ /* Disable I2C0 interrupt */ NVIC_DisableIRQ(I2C0_IRQn); /* preemption = 1, sub-priority = 0 */ NVIC_SetPriority(I2C0_IRQn, ((0x01<<3)|0x01)); /* Enable I2C operation */ I2C_Cmd(LPC_I2C0, ENABLE);
second part :
txsetup.sl_addr7bit = 0xA0; txsetup.tx_data = &BusAddres; txsetup.tx_length = 8; txsetup.retransmissions_max = 3; I2C_MasterTransferData(LPC_I2C0,&txsetup, I2C_TRANSFER_POLLING); txsetup.tx_data = &Reg; I2C_MasterTransferData(LPC_I2C0,&txsetup, I2C_TRANSFER_POLLING); txsetup.tx_data = &Data; I2C_MasterTransferData(LPC_I2C0,&txsetup, I2C_TRANSFER_POLLING);
thank u all..