Other Parts Discussed in Thread: SYSCONFIG, , C2000WARE
Hello guys,
my code is based on TMS320F28375S and i am debugging it in Launchpad 28379D. I have configured I2C by sysconfig tool as shown in image below.
I have knowledge about I2C protocol but i don't know how it is working in ccs (TI controllers)
this is a part of my code which is used for I2C
void main() { myI2C0_init(); //-----------------------------------// // while loop from main() while(1) { while(I2C_isBusBusy(myI2C0_BASE)); // bus check I2C_sendStartCondition(myI2C0_BASE); // start I2C_putData(myI2C0_BASE, 0xB4); // addr + 0 (write) I2C_putData(myI2C0_BASE, 0x20); // read reg no 32 I2C_sendStartCondition(myI2C0_BASE); // repeated start I2C_putData(myI2C0_BASE, 0xB5); // addr + 1 (read) I2C_buf[0] = I2C_getData(myI2C0_BASE); // read MSB I2C_sendNACK(myI2C0_BASE); // send NACK I2C_buf[1] = I2C_getData(myI2C0_BASE); // read LSB I2C_sendNACK(myI2C0_BASE); // send NACK I2C_sendStopCondition(myI2C0_BASE); // stop while (I2C_getStopConditionStatus(myI2C0_BASE)); // stop status } } // I2C init function in Board.c file // void myI2C0_init(){ I2C_disableModule(myI2C0_BASE); I2C_initController(myI2C0_BASE, DEVICE_SYSCLK_FREQ, 400000, I2C_DUTYCYCLE_33); I2C_setConfig(myI2C0_BASE, I2C_CONTROLLER_SEND_MODE); I2C_setTargetAddress(myI2C0_BASE, 90); I2C_disableLoopback(myI2C0_BASE); I2C_setBitCount(myI2C0_BASE, I2C_BITCOUNT_8); I2C_setDataCount(myI2C0_BASE, 2); I2C_setAddressMode(myI2C0_BASE, I2C_ADDR_MODE_7BITS); I2C_disableFIFO(myI2C0_BASE); I2C_setEmulationMode(myI2C0_BASE, I2C_EMULATION_STOP_SCL_LOW); I2C_enableModule(myI2C0_BASE); }
my slave address is 90(decimal).
the I2C is not working as per this. sometimes the bus is busy and sometimes i get stucked while getting stop conditon status.
please help me to get data from AM4096.
thanks in advance.
regards
Muzammil Qureshi