SWRU543B January 2019 – June 2025 CC3230S , CC3230SF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
Most image sensors provide a 2-wire serial interface for external MCUs to control them. This section shows how to use the CC32xx I2C interface to communicate with these image sensors. The CC32xx includes one I2C module operating with standard (100 kbps) or fast (400 kbps) transmission speeds.
First, configure and enable the clock for the I2C peripheral. Peripherals are clock-gated by default and generate a bus fault if accessed without enabling the clock. The peripheral should be ready to use after the software reset.
MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
MAP_PRCMPeripheralReset(PRCM_I2CA0);
The I2C master block must be configured and enabled next in either standard or fast mode, by using the peripheral driver API MAP_I2CMasterInitExpClk. The function internally computes the clock divider to achieve the fastest speed less than or equal to the desired speed.
MAP_I2CMasterInitExpClk (I2C_BASE, SYS_CLK, true); /* SYS_CLK is set to 80MHz */The commands to the image sensor can then be written, and responses can be read. Normally, a standard communication consists of:
The master sends the slave address followed by the START condition. A slave with an address that matches this address responds by returning an acknowledgment bit. When the slave addressing is achieved, data transfer can proceed byte-by-byte.
Peripheral driver APIs for writing and reading to and from an I2C slave:
I2CMasterSlaveAddrSet
I2CMasterDataPut
I2CMasterDataGet
I2CMasterIntClearEx
I2CMasterTimeoutSet
I2CMasterControl
I2CMasterIntStatusEx