Hi,
The values I get when using I2C with system clock set to SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_INT | SYSCTL_XTAL_16MHZ); works fine, but when I increase the system clock to 80 MHz communication still exists, but values are way off. Doesn't make sense to me as I though the clock speed for the I2C clock line would still be set to 100 kbps.
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);//Set clock to 80 MHz
//initialize I2C module 0 void InitI2C0(void) { //enable I2C module 0 SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); //reset module SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0); //enable GPIO peripheral that contains I2C 0 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. 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, SysCtlClockGet() , false); } //read specified register on slave device uint8_t I2CReceive(uint8_t slave_addr, uint8_t reg) { while(I2CMasterBusy(I2C0_BASE)); //specify that we are writing (a register address) to the //slave device I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false); //specify register to be read I2CMasterDataPut(I2C0_BASE, reg); //send control byte and register address byte to slave device I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START); //wait for MCU to finish transaction while(I2CMasterBusy(I2C0_BASE)); //specify that we are going to read from slave device I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, true); //send control byte and read from the register we //specified I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE); //wait for MCU to finish transaction while(I2CMasterBusy(I2C0_BASE)); //return data pulled from the specified register return I2CMasterDataGet(I2C0_BASE); } void I2C_SEND(uint8_t slave_addr, uint8_t reg, uint8_t data) { while(I2CMasterBusy(I2C0_BASE)); I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false); //Send register address on slave device I2CMasterDataPut(I2C0_BASE, reg); I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START); while(I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, data); I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH ); while(I2CMasterBusy(I2C0_BASE)); }