Hello,
I'm using this function to initialize the 2nd I2C module on my TM4C123 :
I2CMInit(&g_sI2CInst, I2C2_BASE, INT_I2C2, 0xFF, 0xFF, SysCtlClockGet());
This gives me an SCL with a frequency of 400 KHz.
How can I change it to 100 KHz ?
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.
Hello,
I'm using this function to initialize the 2nd I2C module on my TM4C123 :
I2CMInit(&g_sI2CInst, I2C2_BASE, INT_I2C2, 0xFF, 0xFF, SysCtlClockGet());
This gives me an SCL with a frequency of 400 KHz.
How can I change it to 100 KHz ?
To run at 100KHz, replace the I2CMInit function with your own copy and change the last argument in the function MAP_I2CMasterInitExpClk to "false".
void I2CMInit(tI2CMInstance *psInst, uint32_t ui32Base, uint_fast8_t ui8Int, uint_fast8_t ui8TxDMA, uint_fast8_t ui8RxDMA, uint32_t ui32Clock) { // // Check the arguments. // ASSERT(psInst); ASSERT((ui32Base == I2C0_BASE) || (ui32Base == I2C1_BASE) || (ui32Base == I2C2_BASE) || (ui32Base == I2C3_BASE) || (ui32Base == I2C4_BASE) || (ui32Base == I2C5_BASE) || (ui32Base == I2C6_BASE) || (ui32Base == I2C7_BASE) || (ui32Base == I2C8_BASE) || (ui32Base == I2C9_BASE)); ASSERT(ui8Int); ASSERT(ui32Clock); // // Initialize the state structure. // psInst->ui32Base = ui32Base; psInst->ui8Int = ui8Int; psInst->ui8TxDMA = ui8TxDMA; psInst->ui8RxDMA = ui8RxDMA; psInst->ui8State = STATE_IDLE; psInst->ui8ReadPtr = 0; psInst->ui8WritePtr = 0; // // Initialize the I2C master module. // MAP_I2CMasterInitExpClk(ui32Base, ui32Clock, false); // // Enable the I2C interrupt. // MAP_IntEnable(ui8Int); MAP_I2CMasterIntEnableEx(ui32Base, I2C_MASTER_INT_DATA); }