This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TIVA TM4C129XNCZAD I2C issue

Other Parts Discussed in Thread: TM4C129XNCZAD

Hi,

I try to interface TM4C129XNCZAD uC to IO expander PCA9505 thru Level translator NTS0104W.
 When we run the microcontroller using debugger with Full run action, data loaded in I2CMDR register
is not reflecting over SDA lines(monitored using Oscilloscope). But when we single step over the code,
data written in I2CMDR register reflects over SDA line. Following is my code:

Please help me in solving this issue.
Thanks & Regards,
Thangavel.P
bool I2C_WriteData(U32 v_I2Cbase_u32r, U8 v_DeviceAddress_u8r, U8 v_RegAddress_u8r,U8* p_source_u8r, 
U8 v_length_u8r) { U16 v_delaycnt_u16r = 0; U8 v_cnt_u8r = 0; if( ROM_I2CMasterBusy(I2C9_BASE) == true /*Is I2C port busy?*/) { /*I2C port is busy. So return false*/ return(false); } else { ROM_I2CMasterSlaveAddrSet(I2C9_BASE, v_DeviceAddress_u8r, false); ROM_I2CMasterDataPut(I2C9_BASE, v_RegAddress_u8r); ROM_I2CMasterControl(I2C9_BASE, I2C_MASTER_CMD_BURST_SEND_START); do{ //wait till I2C is busy while(ROM_I2CMasterBusy(I2C9_BASE)); //check for error if( ROM_I2CMasterErr(I2C9_BASE) != I2C_MASTER_ERR_NONE) { //error. Issue Stop and return false ROM_I2CMasterControl(I2C9_BASE, I2C_MASTER_CMD_BURST_SEND_STOP); return(false); } if(v_cnt_u8r <= (v_length_u8r-1)) { //copy the data to I2C data register ROM_I2CMasterDataPut(I2C9_BASE, *p_source_u8r); if(v_cnt_u8r < (v_length_u8r-1)) { //start txmitting data ROM_I2CMasterControl(I2C9_BASE, I2C_MASTER_CMD_BURST_SEND_CONT); } else { //start txmitting data ROM_I2CMasterControl(I2C9_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH); } } p_source_u8r++; v_cnt_u8r++; }while(v_cnt_u8r < v_length_u8r); while(ROM_I2CMasterBusy(I2C9_BASE)); return(true); } }

  • Hello Thangavel,

    This is an issue that has been reported on the forum quite a number of times. The issue is on the TM4C129 that due to higher system clock v/s low I2C Baud rate, the I2CMasterBusy Flag takes some time to get set in which case the code will execute past it.

    To avoid this you can use while(!(I2CMasterBusy(I2C9_BASE))); along with the I2CMasterBusy statement or add a small delay before the I2CMasterBusy

    Regards

    Amit