Hello Everyone,
Am using TM4C123GH6PM in our own custom board .
We have I2C interface with AT24C1024 EEPROM. but the problem is while am trying to write or read Eeprom .
it always gives below errors
I2C_MASTER_ERR_ADDR_ACK
I2C_MASTER_ERR_DATA_ACK
I attached my code below ..
static void I2c0_Initialize(void) {
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0); ROM_GPIOPinConfigure(GPIO_PB2_I2C0SCL); ROM_GPIOPinConfigure(GPIO_PB3_I2C0SDA); ROM_GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3); ROM_GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); ROM_I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), TRUE); ROM_SysCtlDelay(1000); // ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA, // GPIO_PIN_TYPE_STD_WPU); // ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA, // GPIO_PIN_TYPE_OD); ROM_I2CMasterTimeoutSet(I2C0_BASE, 0xFF); ROM_I2CMasterEnable(I2C0_BASE); // for ic1 st_i2c[0].ui32_baseaddr = I2C1_BASE; st_i2c[0].ui16_startaddr = NULL; st_i2c[0].ui8_length = NULL; st_i2c[0].ui8_ptrdata = NULL; st_i2c[0].ui8_slaveaddr = IC1_ADDRESS; // for ic2 st_i2c[1].ui32_baseaddr = I2C1_BASE; st_i2c[1].ui16_startaddr = NULL; st_i2c[1].ui8_length = NULL; st_i2c[1].ui8_ptrdata = NULL; st_i2c[1].ui8_slaveaddr = IC2_ADDRESS; Uarts_transmit(UART0_BASE, "I2C0_INIT \r\n", 12); } static unsigned char I2c_PageWrite(s_i2c * restrict st_arg1ptr) { if (st_arg1ptr != NULL) { u_us_uc un_us_uc; uint32_t ui32_error = NULL; Uarts_transmit(UART0_BASE, "5\r\n", 3); un_us_uc.us_value = NULL; while (ROM_I2CMasterBusBusy(st_arg1ptr->ui32_baseaddr)) { } ROM_I2CMasterSlaveAddrSet(st_arg1ptr->ui32_baseaddr, st_arg1ptr->ui8_slaveaddr, FALSE); SysCtlDelay(10000); while (ROM_I2CMasterBusBusy(st_arg1ptr->ui32_baseaddr)) { } // if (!I2c_BusyCheck(st_arg1ptr->ui32_baseaddr)) // return FALSE; // to write a address // 1073872896 un_us_uc.us_value = st_arg1ptr->ui16_startaddr; //Msb ROM_I2CMasterDataPut(st_arg1ptr->ui32_baseaddr, un_us_uc.uc_value[1]); // ROM_I2CMasterControl(st_arg1ptr->ui32_baseaddr, // I2C_MASTER_CMD_BURST_SEND_START); ROM_I2CMasterControl(st_arg1ptr->ui32_baseaddr, I2C_MASTER_CMD_BURST_SEND_START); SysCtlDelay(1000); // while (ROM_I2CMasterBusBusy(st_arg1ptr->ui32_baseaddr)) { // Uarts_transmit(UART0_BASE, "B", 1); //} if (I2c_BusyCheck(st_arg1ptr->ui32_baseaddr) == FALSE) return FALSE; ui32_error = ROM_I2CMasterErr(st_arg1ptr->ui32_baseaddr); if (ui32_error != I2C_MASTER_ERR_NONE) { return FALSE; } //Lsb ROM_I2CMasterDataPut(st_arg1ptr->ui32_baseaddr, un_us_uc.uc_value[0]); ROM_I2CMasterControl(st_arg1ptr->ui32_baseaddr, I2C_MASTER_CMD_BURST_SEND_CONT); SysCtlDelay(1000); if (I2c_BusyCheck(st_arg1ptr->ui32_baseaddr) == FALSE) return FALSE; if (ROM_I2CMasterErr(st_arg1ptr->ui32_baseaddr) != I2C_MASTER_ERR_NONE) return FALSE; // Data transmit uint16_t ui16_temp1 = NULL; for (ui16_temp1 = NULL; ui16_temp1 < st_arg1ptr->ui8_length; ui16_temp1++) { ROM_I2CMasterDataPut(st_arg1ptr->ui32_baseaddr, *(st_arg1ptr)->ui8_ptrdata + ui16_temp1); if (ui16_temp1 == (st_arg1ptr->ui8_length - 1)) ROM_I2CMasterControl(st_arg1ptr->ui32_baseaddr, I2C_MASTER_CMD_BURST_SEND_FINISH); else ROM_I2CMasterControl(st_arg1ptr->ui32_baseaddr, I2C_MASTER_CMD_BURST_SEND_CONT); SysCtlDelay(1000); if (!I2c_BusyCheck(st_arg1ptr->ui32_baseaddr)) return FALSE; if (ROM_I2CMasterErr( st_arg1ptr->ui32_baseaddr) != I2C_MASTER_ERR_NONE) return FALSE; } Uarts_transmit(UART0_BASE, "6\r\n", 3); return TRUE; } return FALSE; }
What could be the problem .. can any one give suggestion....
Thanks
Ramasubbu.V