Before enabling the I2C controller, perform the following steps:
- Enable the functional and interface clocks.
- Program the prescaler to obtain an approximately
12-MHz internal sampling clock by programming the
corresponding value in the I2Cn_ICPSC I2C
Prescaler Register IPSC7_IPSC0 bit field. This
value depends on the frequency of the functional
clock (SYS_CLK).
- Take the I2C controller out of reset by setting
the I2Cn_ICMDR[5] IRS bit to 1.
- If using interrupts for transmitting/receiving
data, enable the interrupt masks in the
I2Cn_ICIMR I2C Interrupt Mask
Register.
- If using DMA for transmitting/receiving data,
enable the DMA via the I2Cn_ICDMAC I2C DMA
Control Register and then program the DMA
controller.