How to enable Fast Mode Plus(Fm+) for I2C on STM32L496?
I'm trying to configure the I2C to run at 1Mhz(Fm+) on STM32L496. As per the RM0351, it does support fast mode plus mode. I tried generating the code from STM32Cube IDE and check the SCL pin of logic analyzer. However, I see 400 khz I2C clock frequency. How do I achieve 1Mhz I2C clock?
Configurations:
I2C peripheral: I2C2
I2C clock source: SYSCLK
SYSCLK freq: 80Mhz
Code generated:
/** I2C Initialization
*/
LL_I2C_EnableAutoEndMode(I2C2);
LL_I2C_DisableOwnAddress2(I2C2);
LL_I2C_DisableGeneralCall(I2C2);
LL_I2C_EnableClockStretching(I2C2);
I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C;
I2C_InitStruct.Timing = 0x00B0122F;
//I2C_InitStruct.Timing = 8459040;
I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_DISABLE;
I2C_InitStruct.DigitalFilter = 0;
I2C_InitStruct.OwnAddress1 = 0;
I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK;
I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT;
LL_I2C_Init(I2C2, &I2C_InitStruct);
LL_I2C_SetOwnAddress2(I2C2, 0, LL_I2C_OWNADDRESS2_NOMASK);
/** I2C Fast mode Plus enable
*/
LL_SYSCFG_EnableFastModePlus(LL_SYSCFG_I2C_FASTMODEPLUS_I2C2);
However, I see only 400khz on logic analyzer. Can someone help where I might be getting it wrong?
I'd also like to understand how the timing register value is calculated. I didn't get much from RM. They say use STM32Cube IDE for accurate values.
Thanks,
Abhijit Nathwani
