To easily configure the DCMI GPIOs (such as data pins, control signals pins, camera configuration pins), and to avoid any pin conflicts, it is recommended to use the STM32CubeMX configuration and initialization code generator.
Thanks to the STM32CubeMX, the user generates a project with all the needed peripherals preconfigured.
Depending on the extended data mode chosen by configuring EDM bits in DCMI_CR register, the DCMI receives a 8-, 10-, 12-, or 14-bpp clock (DCMI_PIXCLK).
The user needs to configure:
- 11, 13, 15, or 17 GPIOs for the DCMI for the hardware synchronization
- only nine GPIOs (eight pins for data and one pin for DCMI_PIXCLK) for the embedded synchronization
The user needs to configure also the I2C, and in some cases the camera power supply pin (if the camera power supply source is the STM32 MCU).
Enable interrupts
To be able to use the DCMI interrupts, the user must enable the DCMI global interrupts on the NVIC side. Each interrupt is then enabled separately by enabling its corresponding enable bit in the DCMI_IER register:
- Only four interrupts (IT_LINE, IT_FRAME, IT_OVR, and IT_DCMI_VSYNC) can be used in hardware synchronization mode.
- The five interrupts can be used in embedded synchronization mode.
The software allows the user to check whether the specified DCMI interrupt has occurred or not, by checking the state of the flags.