Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 234571

Forum post: EK-TM4C1294XL: Master stays busy while transmitting data using I2C

$
0
0
Part Number: EK-TM4C1294XL Hello, Master stays busy while transmitting data using I2C. Also, there is no data transmission happening which i have confirmed using CRO. I'm using 24LC256 EEPROM as my slave. I think there is some initialization issue but i;m unable to point it out. Any lead is much appreciated. Below are initialization and TX functions in my source code: extern uint32_t u32_SysClock; const uint32_t u32_slave_addr[3] = { 0x50 , 0x51 , 0x52 , }; void i2c_init(void) { // // The I2C0 peripheral must be enabled before use. // SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); //reset module SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0); // // GPIO port B needs to be enabled so these pins 2 and 3 can // be used. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // // Configure the pin muxing for I2C0 functions on port B2 and B3. // GPIOPinConfigure(GPIO_PB2_I2C0SCL); GPIOPinConfigure(GPIO_PB3_I2C0SDA); // // Select the I2C function for these pins. This function will also // configure the GPIO pins pins for I2C operation, setting them to // open-drain operation with weak pull-ups. // GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3); // // Enable and initialize the I2C0 master module. Use the system clock for // the I2C0 module. The last parameter sets the I2C data transfer rate. // If false the data rate is set to 100kbps and if true the data rate will // be set to 400kbps. // I2CMasterInitExpClk(I2C0_BASE, u32_SysClock, false); //clear I2C FIFOs HWREG(I2C0_BASE + I2C_O_FIFOCTL) = 80008000; // // Enable the I2C0 slave module. This module is enabled only for testing // purposes. It does not need to be enabled for proper operation of the // I2Cx master module. // I2CSlaveEnable(I2C0_BASE); } void i2c_tx(uint32_t device, uint32_t addr, uint32_t u32_TxData) { addr = addr & 0x0000FFFF; I2CSlaveInit(I2C0_BASE, u32_slave_addr[device]); I2CMasterSlaveAddrSet(I2C0_BASE, u32_slave_addr[device], false); // // Place the data to be sent in the data register // I2CMasterDataPut(I2C0_BASE, (addr >> 8)); I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND); // // Wait until the slave has received and acknowledged the data. // while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_RREQ)) { } // // Place the data to be sent in the data register // I2CMasterDataPut(I2C0_BASE, (addr & 0x00FF)); I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND); // // Wait until the slave has received and acknowledged the data. // while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_RREQ)) { } // // Place the data to be sent in the data register // I2CMasterDataPut(I2C0_BASE, u32_TxData); I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND); // // Wait until the slave has received and acknowledged the data. // while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_RREQ)) { } }

Viewing all articles
Browse latest Browse all 234571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>