An5020 Digital Camera Interface Dcmi On Stm32 Mcus Stmicroelectronics
An5020 Digital Camera Interface Dcmi On Stm32 Mcus Stmicroelectronics
Application note
Introduction
As the demand for better and better image quality increases, the imaging domain continually evolves giving rise to a variety of
technologies (such as 3D, computational, motion, and infrared).
Imaging applications require high-quality, ease-of-use, power efficiency, high level of integration, fast time-to-market, and
cost effectiveness. To meet these requirements, the STM32 MCUs embed a digital camera interface (DCMI), which allows
connection to efficient parallel camera modules.
The STM32 MCUs provide many performance levels (CPU, MCU subsystem, DSP, and FPU). They also provide various power
modes, an extensive set of peripheral and interface combinations (for example, SPI, UART, I²C, SDIO, USB, Ethernet, or I2S),
a rich graphical portfolio (such as LTDC, QUADSPI, or DMA2D), and an industry-leading development environment ensuring
sophisticated applications and connectivity solutions (IOT).
This application note gives to the STM32 users some basic concepts, with easy-to-understand explanations of the features,
architecture, and configuration of the DCMI. It is supported by an extensive set of detailed examples.
Refer to the device reference manual and datasheet for more details.
STM32F2x7
STM32F407/417, STM32F427/437, STM32F429/439, STM32F446, STM32F469/479
1 General information
This application note applies to the STM32 Series microcontrollers that are Arm® Cortex® core-based devices.
Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
This section provides a summarized description of camera modules and their main components. It also highlights
the external interface focusing on parallel camera modules.
• vertical blanking: ignored lines between the end of the last line of a frame, and the beginning of the first line
in the next frame
Frame 1
Line n
Vertical blanking
Line 1
Frame2
• progressive scan: a manner of dealing with moving images
The lines can be drawn one after the other in sequence, without separating the odd lines from the even
ones, as for interlaced scan. To construct the image:
– in progressive scan, the first line is drawn, then the second, then the third
– in interlaced scan, each frame is divided in two fields (odd and even lines),
which are displayed alternatively
Image sensor
It is an analog device used to convert the received light into electronic signals. These signals convey the
information that constitutes the digital image.
There are two types of sensors that can be used in digital cameras:
• CCD (charge-coupled device) sensors
• CMOS (complementary metal-oxide semiconductor) sensors
Both types convert the light into electronic signals, but each has its own conversion method. As their performance
continually evolves and their cost decreases, CMOS imagers now dominate the digital photography landscape.
Lens
It is an optic, which allows the reproduction of the real image captured rigorously on the image sensor. Picking
the proper lens is part of the user creativity, and affects considerably the image quality.
Camera module
PIXCLK
Parallel output interface
Power supply
MCU
Digital signal Image data
processing
Serial interface signals
(configuration
signals)
Control register
DT46624V1
• control signals: used for clock generation and data transfer synchronization
The camera clock must be provided according to the camera specification. The camera also provides two
data synchronization signals: HSYNC (for horizontal/line synchronization) and VSYNC (for vertical/frame
synchronization).
• image data signals: each of them transmits a bit of the image data.
Their width represents the number of bits to be transferred at each pixel clock. This number depends on
the parallel interface of the camera module, and on the embedded system interface.
• power supply signals:
As any embedded electronic system, the camera module needs to have a power supply. The operating
voltage of the camera module is specified in its datasheet.
• configuration signals: used for the following:
– to configure the appropriate image features such as resolution, format, and frame rate
– to configure the contrast and the brightness
– to select the type of interface (a camera module can support more than one interface: a parallel and a
serial interface. The user must then choose the most convenient one for the application.)
Most camera modules are parametrized through an I2C communication bus.
This section gives a general preview of the DCMI availability across the various STM32 devices, and gives an
easy-to-understand explanation on the DCMI integration in the STM32 MCUs architecture.
The DCMI is a synchronous parallel data bus, which is used for an easy integration and easy adaptation to
specific application requirements. The DCMI connects with 8-, 10-, 12-, and 14-bit CMOS camera modules, and
supports a multitude of data formats.
Max
Max
FMC(1)
DCMI LCD_ TFT
Max flash On-chip SRAM LCD Max AHB
QUADS pixel JPEG controller MIPI DSI
STM32 line memory SRAM and DMA2D parallel frequency
PI clock codec host(4)
size (Kbytes) SDRAM (3) interface (MHz)
input
frequency
(MHz)(2)
(MHz)
Max
Max
FMC(1)
DCMI LCD_ TFT
Max flash On-chip SRAM LCD Max AHB
QUADS pixel JPEG controller MIPI DSI
STM32 line memory SRAM and DMA2D parallel frequency
PI clock codec host(4)
size (Kbytes) SDRAM (3) interface (MHz)
input
frequency
(MHz)(2)
(MHz)
STM32H747
2 Mbytes 864 Yes 110 80 Yes Yes Yes No No 240
STM32H757
128
STM32H730 564 No 137 110 No Yes Yes No No 275
Kbytes
128
STM32H750 864 Yes 100 80 Yes Yes Yes No No 240
Kbytes
STM32H7A3
2 Mbytes 1180 No 100 80 Yes Yes Yes No No 280
STM32H7B3
STM32L4x6 1 Mbyte 320 Yes 40 32 No Yes No No No 80
STM32L4R9
STM32L4S9
STM32L4R7
2 Mbytes 640 No 60 48 No Yes Yes No Yes 120
STM32L4S7
STM32L4R5
STM32L4S5
STM32L4P5
1 Mbyte 320 No 60 48 No Yes Yes No No 120
STM32L4Q5
STM32U575/
2 Mbytes 786 Yes 80 64 No Yes No Yes No 160
585
STM32U535/ 512
274 Yes No 64 No Yes No No No 160
545 Kbytes
STM32U595/
5A5
4 Mbytes 2514 Yes 80 64 No Yes Yes Yes No 160
STM32U599/
5A9
STM325F7/5
G7
4 Mbytes 3026 Yes 80 64 Yes Yes Yes Yes No 160
STM32U5F9
/5G9
STM32H563/
2 Mbytes 640 Yes 100 96 No No No Yes No 240
573
STM32H562 2 Mbytes 640 Yes 100 96 No No No Yes No 240
GP GP MAC
OTG HS
Cortex-M3 DMA1 DMA2
Eth
ETHERNET_M
DMA_MEM1
DMA_P1
DMA_MEM2
USB_HS_M
DMA_P2
S-bus
D-bus
I-bus
ART
Flash
memory
SRAM1
APB1
SRAM2
APB2
AHB1 periph
DCMI_VSYNC
AHB2 periph
DCMI_HSYNC
FSMC DCMI DCMI_PIXCLK
Bus matrix-S
Data[0:13]
DT46628V1
Pixel path through the DCMI and the DMA Pixel path to the memory destination
32-bit bus width Bus mutliplexer
Figure 7 shows the DCMI interconnection and the data path in these devices.
64-Kbyte
GP GP ETH OTG
CCM data LTDC(5) DMA2D(5)
DMA1 DMA2 MAC(4) _HS
RAM(3) DMA_MEM2
I-bus
D-bus
S-bus
DMA_PI
DMA_MEM1
DMA_P2
ACCEL
Flash
(6) (6) memory
SRAM1(1)
SRAM2(1)
APB1
SRAM3(1)
AHB1 periph APB2
AHB2 periph DCMI_VSYNC
DCMI_HSYNC
FMC(7) DCMI DCMI_PIXCLK
Dual- or
quad-SPI(2) Data[0:13]
Bus Matrix-S
Pixel path through the DCMI and the DMA Pixel path to the memory destination
DT46629V1
Note: 1. See the table below for details on the SRAMs.
2. The dual- or quad-SPI interface is available only in STM32F469/479 and STM32F446 devices.
3. The 64-Kbyte CCM data RAM is not available in STM32F446xx devices.
4. The Ethernet MAC interface is not available in STM32F446xx devices.
5. The LTDC and DMA2D are only available in STM32F429/439 and STM32F469/479 devices.
6. In STM32F407/417 devices, there is no interconnection between:
– the Ethernet master and the DCode bus of the flash memory
– the USB master and the DCode bus of the flash memory
In STM32F446 devices, there is no interconnection between the USB master and the DCODE bus of the
flash memory.
7. It is FMSC for STM32F407/417 devices.
STM32F407/417 N/A
STM32F427/437, STM32F429/439 112 16 64
STM32F446 N/A
STM32F469/479 160 32 128
Figure 8 shows the DCMI interconnection and the data path in these devices.
DTCM
ITCM
AHBS
GP GP ETH OTG
LTDC(2) DMA2D
DMA1 DMA2 MAC _HS
Cortex-M7 DTCM RAM(3)
DMA_MEM1
(1)
DMA_MEM2
DMA_P2
DMA_PI
L1-cache
AXIM AHBP ITCM RAM(4)
AXI to
multi-AHB
ITCM
ART
Flash
memory
64-bit AHB
64-bit Bus Matrix
APB1
SRAM1(5)
APB2
SRAM2(6)
AHB1 periph
DCMI_VSYNC
AHB2 periph DCMI_HSYNC
DCMI DCMI_PIXCLK
FMC
Dual- or
Data[0:13]
quad-SPI
32-bit Bus Matrix - S
Figure 9 shows the DCMI interconnection and the data path in these devices.
AHBS ITCM
CPU 64 Kbytes
Cortex-M7 ITCM1 92
OR
Kbytes(5) ETH
I$ D$ DMA1 DMA2 SDMMC2 USBHS1 USBHS2(6)
DTCM MAC
128 Kbytes
AHBP
AXIM
DMA2_PERIPH
DMA1_PERIPH
DMA2_MEM
DMA1_MEM
SDMMC1 MDMA DMA2D LTDC
D1-to-D2 AHB
AXI SRAM
192 Kbytes(5) SRAM1 (9)
Flash B(1)
AXI SRAM3 (7)(9)
SRAM(9)
DCMI_VSYNC
OTFDEC1(3) OCTOSPI1(2)
AHB1
DCMI_HSYNC
FMC APB1
Data[0:13]
QUADSPI(4) APB2
AHB3 APB3
(8)
DT71188V1
TCM AHB
AXI APB
Master interface
Slave interface
Note: 1. Flash B is not available in STM32H723/733, STM32H725/735, STM32H730, and STM32H750 devices.
2. OCTOSPI1 and 2 are not available in STM32H743/753, STM32H742, and STM32H750 devices.
3. OTFDEC1 and 2 are only available in STM32H723/733, STM32H725/735, and STM32H730 devices.
4. The QUADSPI is only available in STM32H743/753, STM32H742, and STM32H750 devices.
5. The 192-Kbyte AXI SRAM and the 92-Kbyte ITCM are only available inSTM32H723/733, STM32H725/735,
and STM32H730 devices.
6. The USBHS2 is only available in STM32H743/753, STM32H742, and STM32H750 devices.
7. The SRAM3 is only available in STM32H743/753, STM32H74,2 and STM32H750 devices.
8. There is no connection between the APB3 and the D2 domain in STM32H723/733, STM32H725/735,
STM32H730, and STM32H750 devices.
9. See Table 4 for more details on the SRAM1, SRAM2, SRAM3 and the AXI SRAM.
STM32 line SRAM1 (Kbytes) SRAM2 (Kbytes) SRAM3 (Kbytes) AXI SRAM (Kbytes)
STM32H723/733 16 16 X 128
STM32H725/735 16 16 X 128
STM32H730 16 16 X 128
STM32 line SRAM1 (Kbytes) SRAM2 (Kbytes) SRAM3 (Kbytes) AXI SRAM (Kbytes)
Figure 10. DCMI slave AHB2 peripheral in STM32H745/755 and STM32H747/757 devices
AHBS
CPU
ITCM CPU
Cortex-M7 64 Kbytes
Cortex-M4
I$ D$ DTCM ETH
128 Kbytes
DMA1 DMA2 SDMMC2 USBHS1 USBHS2
16 KB 16 KB MAC
AHBP
AXIM
DMA1_PERIPH
DMA2_PERIPH
DMA1_MEM
DMA2_MEM
D-bus
S-bus
D1-to-D2 AHB
I-bus
SRAM1
APB3 128 Kbytes
SRAM2
AHB3
128 Kbytes
SRAM3
Flash A 32 Kbytes
up to 1 Mbyte
AHB1 DCMI_VSYNC
Flash B
up to1 Mbyte DCMI_HSYNC
AHB2 DCMI DCMI_PIXCLK
AXI SRAM
512 Kbytes
APB1
QUADSPI
APB2
FMC
D2-to-D1 AHB
D2-to-D3 AHB
D1-to-D3 AHB
BDMA
Pixel path through the DCMI and DMA1
DT71189V1
D3 domain
TCM AHB
AXI APB
Master interface
Slave interface
DT71187V1
Note: OTFDEC1/2 are only available in the STM32H7B3 devices.
Figure 12 shows the DCMI interconnection and the data path in these devices.
ICode
ACCEL
Flash memory
DCode (1 Mbyte)
SRAM1
SRAM2
AHB1periph
DCMI_VSYNC
AHB2 periph
DCMI_HSYNC
DCMI DCMI_PIXCLK
FMC
Data[0:13]
QUADSPI
Bus matrix-S
DT46631V1
Pixel path through the DCMI and the DMA Pixel path to the memory destination
32-bit bus width Bus mutliplexer
Cortex®-M4 with FPU DMA1 DMA2 DMA2D LCD-TFT SDMMC1 SDMMC2(2) GFXMMU(1)
D-bus
S-bus
I-bus
ICode
ACCEL
Flash
memory
DCode 2 Mbytes
SRAM1(3)
SRAM2(4)
SRAM3(5)
GFXMMU
AHB1
peripherals
DCMI_VSYNC
AHB2 DCMI_HSYNC
peripherals DCMI DCMI_PIXCLK
Data[0:13]
FSMC
OCTOSPI1
OCTOSPI2
Bus matrix-S
DT71190V1
Pixel path through the DCMI and DMA2 32bit bus width
APB1 peripherals
SDMM SDMM
GPDMA1 DMA2D(1) OTG_HS(2) LTDC(2) GPU2D(2) GFXMMU(2)
C1 C2(1)
S-bus
ICACHE(8/32-Kbyte)
Port 0
Port 1
M0 port
M1 port
Fast-bus
Slow-bus
DCACHE1 DCACHE2
(4/16-Kbyte) (16-Kbyte)(2)
Flash memory
(512 Kbytes/
2/4 Mbytes)
MPCBB1 SRAM1(4)
MPCBB2 SRAM2(4)
MPCBB3(1) SRAM3(1)(4)
MPCBB5(2) SRAM5(2)(4)
MPCBB6(3) SRAM6(3)(4)
AHB1
MPCWM4
BKPSRAM
peripherals (4)
DCMI_VSYNC
DCMI_HSYNC
AHB2
DCMI DCMI_PIXCLK
peripherals
Data[0:13]
MPCWM1 OTFDEC1 OCTOSPI1
MPCWM5 OCTOSPI2
(1)
OTFDEC2 (1)
(1)
MPCWM6 HSPI1(2)
(2)
MPCWM2
MPCWM3 FSMC(1)
(1)
MPCBB4 SRAM4(4)
SRD
AHB3
32-bit bus matrix peripherals
Pixel path through the DCMI and GPDMA1 MPCBBx: Block-based memory protection controller
Pixel path to the memory destination MPCWMx: Watermark-based memory protection controller
Bus multiplexer Master Interface
Fast bus multiplexer
Fast bus multiplexer on STM32U59x/5Ax/5Fx/5Gx Slave Interface
STM32U535/
192 64 x 16 x x 2
545
STM32U575/
192 64 512 16 x x 2
585
STM32U595/
5A5
768 64 832 16 832 x 2
STM32U599/
5A9
STM32U5F7/
5G7
768 64 832 16 832 512 2
STM32U5F9/
5G9
Cortex-M33 ETHERNET
GPDMA1 GPDMA2 SDMMC1 SDMMC2
with TrustZone mainline and FPU MAC
C-bus
S-bus
Port 1
Port 0
Port 1
Port 0
ICACHE
(8-Kbyte)
Slow-bus
Fast-
bus
DCACHE
(4-Kbyte)
Flash (2 Mbytes)
SRAM1
MPCBB1
256 Kbytes
SRAM2
MPCBB2
64 Kbytes
SRAM3
MPCBB3 320 Kbytes
AHB1 BKPSRAM
MPCWM4 4 Kbytes
peripherals
DCMI_VSYNC
DCMI_HSYNC
AHB2 DCMI DCMI_PIXCLK
peripherals
Data[0:13]
MPCWM2 FMC
AHB4
peripherals
AHB3
peripherals
32-bit bus matrix
Master Interface
Slave Interface
Bus multiplexer
Fast bus multiplexer
MPCBBx: Block-based memory protection controller
MPCWMx: Watermark-based memory protection controller
DT71617V1
Pixel path through the DCMI and GPDMA1
Pixel path through the DCMI and GPDMA2
Pixel path to the memory destination
Many STM32 reference boards are available. Most of them embed the DCMI, and some of them have an onboard
camera module. The board selection depends on the application and the hardware resources. The table below
summarizes the DCMI, the camera modules, and the memories availability across various STM32 boards.
STM3220G-EVAL OV2640 or
STM32F2x7 Yes(1) 132
STM3221G-EVAL OV9655
1. Possible cameras to be connected: module CN01302H1045-C (CMOS sensor OV9655, 1.3 Mpixel) and module CN020VAH2554-C
(CMOS sensor OV2640, 2 Mpixel)
2. N/A means not available. The application must use the desired camera module compatible with the DCMI interface.
3. The camera module can be connected to the DCMI through the GPIO pins.
5 DCMI description
This section details the DCMI, and its manner of dealing with the image data and the synchronization signals.
Note: The DCMI supports only the slave input mode.
Data [31:0]
DCMI_D[0:13]
DCMI External
DCMI_PIXCLK interface
DCMI interrupt DCMI_HSYNC
If x-bit data width is chosen (x data lines are enabled, x = 8, 10, 12, or 14), x bits of image (or video) data are
transferred each DCMI_PIXCLK cycle, and packed into a 32-bit register.
DMA request
Bit_0
Synchronizer
DCMI_VSYNC
D0[0..11]
DCMI interrupt
DCMI_HSYNC
D2[0..11]
D4[0..11]
D6[0..11]
D8[0..11]
DCMI_PIXCLK
4-word FIFO
0000
Data Bit_15 D0
Data extractor
D1
D1[0..11]
D3[0..11]
D5[0..11]
D7[0..11]
D9[0..11] D13
Bit_27
0000
DT46633V2
Bit_31
• The DCMI synchronizer ensures the control of the ordered sequencing of the data flow through the DCMI.
It controls the data extractor, the FIFO and the 32-bit register.
• The data extractor ensures the extraction of the data received by the DCMI.
• The 4-word FIFO is implemented to adapt the data rate transfers to the AHB. There is no overrun
protection to prevent data from being overwritten if the AHB does not sustain the data transfer rate. In
case of overrun or errors in the synchronization signals, the FIFO is reset, and the DCMI waits for a new
start of frame.
• A 32-bit data register where the data bits are packed to be transferred through a general-purpose DMA
channel. The placement of the captured data in 32-bit register depends on the data width:
– For an 8-bit data width, the DCMI captures the eight LSBs (the six other inputs D[13:8] are ignored).
The first captured data byte is placed in the LSB position the 32-bit word, and the fourth captured
data byte is placed in the MSB position. In this case, a 32-bit data word is made up every four pixel
clock cycles. For more details, see Section 5.6.
Bit number 31 24 23 16 15 8 7 0
– For a 10-bit data width, the DCMI captures the 10 LSBs (the four other inputs D[13:10] are ignored).
The first 10 bits captured are placed as the 10 LSBs of a 16-bit word. The remaining MSBs in the
16-bit word of the DCMI_DR register (bits 10 to 15) are cleared. In this case, a 32-bit data word is
made up every two pixel clock cycles.
Bit number 31 26 25 16 15 10 9 0
– For a 12-bit data width, the DCMI captures the 12-bit LSBs (the two other inputs D[13:12] are
ignored). The first 12 bits captured are placed as the 12 LSBs of a 16-bit word. The remaining MSBs
in the 16-bit word of the DCMI_DR register (bits 12 to 15) are cleared. In this case, a 32-bit data word
is made up every two pixel clock cycles.
Bit number 31 28 27 16 15 12 11 0
– For a 14-bit data width, the DCMI captures all the received bits. The first 14 bits captured are placed
as the 14 LSBs of a 16-bit word. The remaining MSBs in the 16-bit word of the DCMI_DR register
(bits 14 and 15) are cleared. In this case, a 32-bit data word is made up every two pixel clock cycles.
Bit number 31 30 29 16 15 14 13 0
HSYNC
VSYNC
PIXCLK
DCMI
Data signals
(up to 14)
DT46653V1
DCMI_VSYNC signals are ignored. Only eight data signals are used.
If the DCMI_VSYNC and DCMI_HSYNC signals are programmed active level (active high or active low), the data
is not valid in the parallel interface when VSYNC or HSYNC is at that level (high or low).
For example, if VSYNC is programmed active high:
• When VSYNC is low, the data is valid.
• When VSYNC is high, the data is not valid (vertical blanking).
The DCMI_HSYNC and DCMI_VSYNC signals act like blanking signals, since all data received during
DCMI_HSYNC/DCMI_VSYNC active periods are ignored.
Figure 23 shows an example of data transfer when DCMI_VSYNC and DCMI_HSYNC are active high, and when
the capture edge for DCMI_PIXCLK is the rising edge.
DCMI_PIXCLK
DCMI_HSYNC
DCMI_VSYNC
Data line
Each synchronization code consists of 4-byte sequence 0xFF 00 00 XY (as shown in Figure 24), where all
delimiter codes have the same first 3-byte sequence 0xFF 00 00. Only the final one 0xXY is programmed to
indicate the corresponding event.
5.4.2.1 Mode 1
This mode is ITU656 compatible (ITU656 is the digital video protocol ITU-R BT.656).
The following reference codes indicate a set of four events:
• SAV (active line): line-start
• EAV (active line): line-end
• SAV (blanking): line-start during inter-frame blanking period
• EAV (blanking): line-end during inter-frame blanking period
Figure 25 illustrates the frame structure using this mode.
SAV EAV
Vertical (or frame) blanking
(blanking) (blanking)
DataLine_0
Horizontal
SAV EAV
(or line)
(active line) (active line)
blanking
DataLine_N
SAV EAV
Vertical (or frame) blanking
(blanking) (blanking)
Synchronization code Data Blanking
DT46640V1
5.4.2.2 Mode 2
The embedded synchronization codes signal another set of events:
• frame-start (FS)
• frame-end (FE)
• line-start (LS)
• line-end (LE)
A 0xFF value programmed as a frame-end (FE) means that all the unused codes (the possible values of codes
other than FS, LS, LE) are interpreted as valid FE codes.
In this mode, once the camera interface has been enabled, the frame capture starts after the first occurrence of
an FE code followed by an FS code.
Horizontal
LE
(or line)
LS blanking
DataLine_N FE
Vertical (or frame) blanking
DT46641V1
Note: The camera modules can have up to eight synchronization codes in interleaved mode. This mode is then not
supported by the camera interface (otherwise, every other half frame is discarded). When using the embedded
synchronization mode, the DCMI does not support the compressed data (JPEG) and the crop feature.
Example: FSC = 0xA5 and unmask code FSU = 0x10 (as shown in Figure 27). In this case the frame-start
information is embedded in the bit number 4 of the FS code. The user must compare only the bit number 4 of the
received code with the bit number 4 of the programmed code, to know if it is a frame-start event or not.
FSC = 0xA5 1 0 1 0 0 1 0 1
FSU = 0x10 0 0 0 1 0 0 0 0
Note: Make sure that each synchronization code has different unmask code to avoid synchronization errors.
Capture bit
DCMI_HSYNC
DCMI_VSYNC
In this mode, the DCMI can be configured to capture all the frames, every alternate frame (50% bandwidth
reduction), or one frame out of four (75% bandwidth reduction). The camera interface is not automatically
disabled but the user must disable it by setting CAPTURE = 0 . After being disabled by the user, the DCMI
continues to grab data until the end of the current frame.
Capture bit
DCMI_HSYNC
DCMI_VSYNC
Received data
DT46644V1
5.6 Data formats and storage
The DCMI supports the following data formats:
• 8-bit progressive video: either monochrome or raw Bayer
• YCbCr 4:2:2 progressive video
• RGB565 progressive video
• compressed data (JPEG)
For monochrome, RGB or YCbCr data, the maximum input size is 2048 * 2048 pixels, and the frame buffer is
stored in raster mode. There is no size limitation for JPEG compressed data.
For monochrome, RGB and YCbCr, the frame buffer is stored in raster mode as shown in Figure 30.
Passing to the
next line
Row n
Note: Only 32-bit words are used, and only the little-endian format is supported (the least significant byte is stored in
the smallest address).
Data received from the camera can be organized in lines, frames (raw YUV/RGB/Bayer modes), or can be a
sequence of JPEG images.
The number of bytes in a line may not be a multiple of four. The user must therefore be careful when handling
this case since a DMA request is generated each time a complete 32-bit word has been constructed from the
captured data. When an end of frame is detected and the 32-bit word to be transferred has not been completely
received, the remaining data are padded with zeros, and a DMA request is generated.
5.6.1 Monochrome
The DCMI supports the monochrome format 8 bpp. In the case an 8-bit data width is selected when configuring
the DCMI, the data register has the structure shown in Figure 31.
DCMI_DR Dn + 3 Dn + 2 Dn+1 Dn
31 24 23 16 15 8 7 0
Bit number
5.6.2 RGB565
RGB refers to Red, Green, and Blue, which represent the three hues of light. Any color is obtained by mixing
these three colors.
565 is used to indicate that each pixel consists of 16 bits divided as follows:
• 5 bits for encoding the red value (the most significant 5 bits)
• 6 bits for encoding the green value
• 5 bits for encoding the blue value (the less significant 5 bits)
Each component has the same spatial resolution (4:4:4 format): each sample has a red (R), a green (G) and a
blue (B) component. Figure 32 shows the DCMI data register containing RGB data, when an 8-bit data width is
selected.
DCMI_DR Rn + 1 Gn + 1 Bn + 1 Rn Gn Bn
Bit number 31 27 26 21 20 16 15 11 10 5 4 0
5.6.3 YCbCr
YCbCr is a family of color spaces that separates the luminance or luma (brightness) from the chrominance or
chroma (color differences).
YCbCr consists of three components:
• Y refers to the luminance or luma (black and white).
• Cb refers to the blue difference chroma.
• Cr refers to the red difference chroma.
YCbCr 4:2:2 is a subsampling scheme, which requires a half resolution in horizontal direction: for every two
horizontal Y samples, there is one Cb or Cr sample.
Each component (Y, Cb, and Cr) is encoded in 8 bits. Figure 33 shows the DCMI data register containing YCbCr
data when an 8-bit data width is selected.
Bit number 31 24 23 16 15 8 7 0
DCMI_DR Yn + 3 Yn + 2 Yn+1 Yn
Bit number 31 24 23 16 15 8 7 0
5.6.5 JPEG
For compressed data (JPEG), the DCMI supports only the hardware synchronization, and the input size is not
limited. Each JPEG stream is divided into packets, which have programmable size. The packet dispatching
depends on the image content, and results in a variable blanking duration between two packets.
To allow JPEG image reception, the JPEG bit must be set to one in the DCMI_CR register. The JPEG images are
not stored as lines and frames. The DCMI_VSYNC signal is used to start the capture while DCMI_HSYNC serves
as a data enable signal.
If the full data stream finishes and the detection of an end of stream does not occur (DCMI_VSYNC does not
change), the DCMI pads out the end of the frame by inserting zeros: if the stream size is not a multiple of four, at
the end of the stream, the DCMI pads the remaining data with zeros.
Note: The crop feature and embedded synchronization mode cannot be used in the JPEG format.
JPEG data
DCMI_HSYNC
DCMI_VSYNC
Data packet Padding data at the end of JPEG stream Begin/end of JPEG stream
DT46650V1
5.7 Crop feature
With the crop feature, the camera interface selects a rectangular window from the received image. The start
coordinates (upper-left corner) are specified in the 32-bit DCMI_CWSTRT register.
The window size is specified in number of pixel clocks (horizontal dimension), and in number of lines (vertical
dimension) in the DCMI_CWSIZE register.
Figure 36 shows one frame when receiving only one byte out of four and one line out of two.
Line 0 B3 B2 B1 B0 B3 B2 B1 B0 B3 B2B2 B3 B2 B1 B0
B3 B2 B1 B0 B3 B2 B1 B0 B3 B2B2 B3 B2 B1 B0
Ignored line
B3 B2 B1 B0 B3 B2 B1 B0 B3 B2B2 B3 B2 B1 B0
Ignored Received
VSYNC event
LINE_RIS
LINE_MIS VSYNC_RIS
VSYNC_MIS ERR_RIS
IT_DCMI
ERR_MIS OVR_RIS
OVR_MIS FRAME_RIS
VSYNC_IE
ERR_IE
DCMI peripheral OVR_IE
DT46652V1
FRAME_IE
DCMI_IER register
The table below summarizes the DCMI operation in the different modes.
Run
Low-power Run(1)
Active
Sleep
Low-power Sleep(1)
Stop
Stop 0(2)
Stop 2(2)
Stop 3(3)
Standby
Powered down
Shutdown(2)
6 DCMI configuration
When selecting a camera module to interface with STM32 MCUs, the user must consider some parameters such
as the pixel clock, the supported data format, and the resolutions.
To correctly implement the application, the user needs to perform the following configurations:
• Configure the GPIOs.
• Configure the timings and the clocks.
• Configure the DCMI peripheral.
• Configure the DMA.
• Configure the camera module:
– Configure the I2C to allow the camera module configuration and control.
– Set parameters such as contrast, brightness, color effect, polarities, and data format.
Note: It is recommended to reset the DCMI and the camera module before starting the configuration. The DCMI can
be reset by setting the corresponding bit in the RCC_AHB2RSTR register, which resets the clock domains.
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.
The clock configurations providing the highest performances are the following:
• for STM32F2x7 devices, HCLK @ 120 MHz and SRAM @ 60 MHz
• for STM32F407/417 devices, HCLK @ 168 MHz and SRAM @ 60 MHz
• for STM32L4x6 devices, HCLK @ 80 MHz and SRAM @ 40 MHz
Bit number 31 24 23 16 15 8 7 0
FF 00 00 FEC
Before the reception of this FEC code, VSYNC must be set to one in DCMI_SR to indicate a valid frame. After
the reception of the FEC, VSYNC must be cleared to zero to indicate that it is synchronization between frames.
VSYNC must remain at zero until the reception of the next frame-start code.
If FEC = 0xFF (the camera module sends 0xFF 00 00 FF), all the unused codes are interpreted as frame-end
codes. There are 253 values corresponding to the end-of-frame delimiter (0xFF0000FF and the 252 unused
codes).
FF 00 00 LEC
FF 00 00 FSC
FF 00 00 LSC
In this embedded synchronization mode, HSPOL and VSPOL bits are ignored. While the DCMI receives data
(CAPTURE = 1 in DCMI_CR), the user can monitor the data flow to know if it is an active line/frame or a
synchronization between lines/frames, by reading VSYNC and HSYNC in DCMI_SR.
If ERR_IE = 1 in DCMI_IER, an interrupt is generated each time an error occurs (such as embedded
synchronization characters not received in the correct order).
FF 00 00 FSC FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC
FF 00 00 LSC data data data data data data data data FF 00 00 LEC FF 00 00 FEC
Figure 44 shows the DMA2 (or the DMA1 for STM32H7 and STM32L4+ devices, the GPDMA1 for STM32U5
devices, the GPDMA1 or the GPDMA2 for STM32H5 devices) operation in peripheral-to-memory mode, except
for STM32L496xx and STM32L4A6xx devices. The DMA2 in these devices has only one port.
DMA2 DMA_SxM0AR
DMA_SxM1AR(1)
AHB
Memory bus
memory bus
Req_streamx FIFO Memory destination
Arbiter FIFO (camera frame buffer)
level
AHB
Peripheral bus
periph. bus
Peripheral source
DMA_SxPAR (DCMI)
DT46660V1
Data path through the DMA Note 1: DMA_SxM1AR is configured for double-buffer mode.
The tables below summarize the DMA stream and channels that enable the DMA request from the DCMI.
STM32F2
STM32F4 Stream 1 and Stream 7 Channel 1
STM32F7
STM32H7 Stream 0 to stream 7 Multiplexer1 request 75
Stream 0 Channel 6
STM32L4
Stream 4 Channel 5
Note: See the reference manual for a step-by-step description of the stream and channel configuration procedure.
Table 10. Maximum number of bytes transferred during one DMA transfer
65535 262140
Words
0 < N < 35535 4*N
Note: To avoid data corruption, this programmed value must be a multiple of MSIZE or PSIZE.
Item Max number of bytes Bit depth (byte/pixel) Max number of pixels Max resolution
1 262140 720x364
Word 262140
2 131070 480x272
Figure 45 shows the DMA_SxNDTR value and the frame buffer pointer modifications during a DMA transfer and
between two successive DMA transfers.
N - 3 Adress 00
Address
N - 2
Pointer
N - 1 reinitialization
between
N Pointer two sucessive
Incrementation DMA transfers
0 during DMA
transfer
1
Address
Adress NN1
2
Frame buffer
Number of data to transfer
(DMA_SxNDTR content)
decrementationin circular mode
programmed
Max number of Bit depth (byte/
Item value in the Number of pixels Max resolution
bytes pixel)
register
65535 524280
1 960x544
0 < N < 65535 8*N
Word 524280
65535 262140
2 720x364
0 < N < 65535 4*N
In this mode, the double-buffer stream has two pointers (two buffers for storing data), switched each end of
transaction:
• In snapshot mode, the DMA controller writes the data in the first frame buffer. After this first frame buffer
is fulfilled (at this level, the register is reinitialized to the programmed value, and the DMA pointer switches
to the second frame buffer), data are transferred to the second buffer. The total frame size (in words) is
divided by two and programmed in the register. The image is stored in two buffers having the same size.
• In continuous mode, each time one frame (image) is received and stored in the two buffers. As the circular
mode is enabled, the register is reinitialized to the programmed value (total frame size divided by two), and
the DMA pointer switches to the first frame buffer to receive the next frame.
The double-buffer mode is enabled by setting DBM = 1 in DMA_SxCR.
Figure 46 shows the two pointers and the DMA_SxNDTR value modifications during the DMA transfers.
Pointer
reinitialization
between two
sucessive DMA
N 3 Address0_0 transfers Address1_0
Adress 0
N 2
N 1
Pointer
N
Incrementation
0 during DMA
transfer
1
Address0_N Address1_N
2
Firstframe buffer used by the DMA Second
Number of data to transfer frame buffer
(DMA_SxNDTR content) decrementation (not used by the DMA)
Start of one DMA transfer End of one DMA transfer
Figure 47 illustrates the DMA_SxM0AR and DMA_SxM1AR update during the DMA transfer:
Buffer 0 Buffer 1
CT=0 = = Buffer 2 Buffer 3 Buffer 14 Buffer 15
Memory 0 Memory 1
Cycle 2 DMA_SxM1AR
DMA_SxM0AR
Buffer 2 Buffer 3
CT=0 Buffer 0 Buffer 1 = = Buffer 14 Buffer 15
Memory 0 Memory 1
DMA_SxM0AR DMA_SxM1AR
Cycle 14
7.2 Performance
For all STM32 MCUs, the number of bytes to be transferred at each pixel clock depends on the extended data
mode:
• When the DCMI is configured to receive 8-bit data, the camera interface takes four pixel clock cycles to
capture a 32-bit data word.
• When the DCMI is configured to receive 10-, 12-, or 14-bit data, the camera interface takes two pixel clock
cycles to capture a 32-bit data word.
The table below summarizes the maximum data flow depending on the data width configuration.
In some applications, the DMA2 (or the DMA1 for STM32H7 and STM32L4+, the GPDMA1 for STM32U5,
the GPDMA1 and GPDMA2 for STM32H5) is configured to serve in parallel other requests together with the
DCMI request. In this case, the user must pay attention to the stream priority configurations, and consider the
performance impact when the DMA serves other streams in parallel with the DCMI.
For better performance, when using the DCMI in parallel with other peripherals having requests that can be
connected to either DMA1 or DMA2, it is better to configure these streams to be served by the DMA that is not
serving the DCMI.
The user must make sure the pixel clock configured on the camera module side is supported by the DCMI to
avoid the overrun.
It is recommended to use the highest system speed HCLK for better performance, but the user must consider the
speed of all the peripherals used (for example external memories speed) to avoid the overrun and to guarantee
the application success.
The DCMI is not the only AHB2 peripheral but there are many other peripherals. The DMA is not the only
master that can access the AHB2 peripherals. Using many AHB2 peripherals or other master accessing the AHB2
peripherals leads to a concurrency on the AHB2: the user must consider its impact on performance.
This section details how to use the DCMI, and provides step-by-step implementation examples .
Storage Internet
Display
USB DSI
Cortex- OTG MAC
DMA DMA2D
ETH STM32
M HS LTDC
Bus matrix
Dual
USART SDIO DCMI RAM FMC QUAD
SPI
QUADSPI
Storage SDRAM
Capture
DCMI_CaptureMode
STM32CubeF2 SnapshotMode STM3220G-EVAL, STM3221G‑EVAL
Camera_To_USBDisk
DCMI_CaptureMode
STM32446E‑EVAL, STM32429I‑EVAL1,
STM32CubeF4 SnapshotMode
STM32469I‑EVAL, STM3240G‑EVAL
Camera_To_USBDisk
DCMI_CaptureMode
SnapshotMode STM32756G-EVAL, STM32F769I‑EVAL
STM32CubeF7
Camera_To_USBDisk
Camera STM32F7508-DISCOVERY
DCMI_CaptureMode
STM32CubeH7 STM32H747I-DISCOVERY
SnapshotMode
DCMI_CaptureMode 32L496GDISCOVERY, 32L4R9IDISCOVERY
STM32CubeL4 SnapshotMode
32L496GDISCOVERY
DCMI_Preview
STM32CubeU5 DCMI_ContinousCap_EmbeddedSynchMode STM32U575I-EVAL
RGB
Cortex-M7 DMA2D DMA2 LTDC
L1-Cache FIFO
Bus matrix
Camera SDRAM
DT46668V1
For these examples, the user needs to configure the DCMI, the DMA2, the LTDC (for the RGB data capture and
display example), and the SDRAM.
The five examples described in the next sections have some common configurations based on STM32CubeMX:
• GPIO configuration
• DMA configuration
• clock configuration
The following specific configurations are needed for Y-only and JPEG capture examples:
• DCMI configuration
• camera module configuration
The next sections provide the hardware description, the common configuration using STM32CubeMX, and
the common modifications that have to be added to the STM32CubeMX generated project.
The STM32F4DIS-CAM board includes an Omnivision CMOS sensor (ov9655), 1.3 Mpixels. The resolution can
reach 1280x1024. This camera module is connected to the DCMI via a 30-pin FFC.
The 32F746GDISCOVERY board features a 4.3-inch color LCD-TFT with capacitive touch screen that is used
in the first example to display the captured images.
As shown in Figure 51, the camera module is connected to the STM32F7 through:
• control signals DCMI_PIXCLK, DCMI_VSYNC, DCMI_HSYNC
• image data signals DCMI_D[0..7]
Additional signals are provided to the camera module through the 30-pin FFC:
• power supply signals (DCMI_PWR_EN)
• clock for the camera module (Camera_CLK)
• configuration signals (I2C)
• reset signal (DCMI_NRST)
For more details on these signals, refer to Section 2.2.2 Camera module interconnect (parallel interface).
The camera clock is provided to the camera module through the Camera_CLK pin, by the NZ2520SB crystal
clock oscillator (X1) embedded on the 32F746GDISCOVERY board. The frequency of the camera clock is equal
to 24 MHz.
The DCMI reset pin (DCMI_NRST) used to reset the camera module is connected to
the global MCU reset pin (NRST).
For more details on the 32F746GDISCOVERY board, refer to the user manual Discovery kit for STM32F7 Series
with STM32F746NG MCU (UM1907) available on the STMicroelectronics website.
If, after selecting one hardware configuration (Slave 8 bits External Synchro for example), the used GPIOs
do not match with the hardware, the user can change the desired GPIOs, and configure the alternate
function directly on the pin.
Another method consists of configuring manually the GPIO pins by selecting the right alternate function for
each of them. For more details on the GPIOs that must be configured, refer to Figure 55.
After this step, 11 pins must be highlighted in green (D[0..7], DCMI_VSYNC, DCMI_HSYNC, and
DCMI_PIXCLK).
2. Select the Configuration tab to configure the GPIOs mode.
3. When the DCMI configuration window appears, select the GPIO Settings tab.
2. Set the different parameters (vertical synchronization, horizontal synchronization, and pixel clock polarities)
that must be programmed according to the camera module configuration.
Note: The vertical synchronization polarity must be active high, and the horizontal synchronization polarity must be
active low. They must not be inverted for this configuration of the camera module.
3. Click on Select under DMA Request, and choose DCMI. The DMA2 Stream 1 channel 1 is configured to
transfer the DCMI request each time its time register is fulfilled.
2. In Pinout & Configuration tab system core, click on the GPIO button.
2. Set the PLLs and the prescalers in the Clock Configuration tab, to get the system clock HCLK @ 200 MHz.
Some variable declarations must then be inserted in the adequate space indicated in bold below.
/* USER CODE BEGIN PV */
/* Private variables ----------------------------------------------------*/
typedef enum
{
CAMERA_OK = 0x00,
CAMERA_ERROR = 0x01,
CAMERA_TIMEOUT = 0x02,
CAMERA_NOT_DETECTED = 0x03,
CAMERA_NOT_SUPPORTED = 0x04
} Camera_StatusTypeDef;
typedef struct
{
uint32_t TextColor;
uint32_t BackColor;
sFONT *pFont;
}LCD_DrawPropTypeDef;
typedef struct
{
int16_t X;
int16_t Y;
}Point, * pPoint;
static LCD_DrawPropTypeDef DrawProp[2];
LTDC_HandleTypeDef hltdc;
LTDC_LayerCfgTypeDef layer_cfg;
static RCC_PeriphCLKInitTypeDef periph_clk_init_struct;
CAMERA_DrvTypeDef *camera_driv;
/* Camera module I2C HW address */
static uint32_t CameraHwAddress;
/* Image size */
uint32_t Im_size = 0;
/* USER CODE END PV */
The function prototypes must also be inserted in the adequate space indicated in bold below.
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------*/
uint8_t CAMERA_Init(uint32_t );
static void LTDC_Init(uint32_t , uint16_t , uint16_t , uint16_t, uint16_t
);
void LCD_GPIO_Init(LTDC_HandleTypeDef *, void *);
/* USER CODE END PFP */
2. Update main() function by inserting some functions in the adequate space (indicated in bold below).
– LTDC_Init allows the configuration and initialization of the LCD.
– BSP_SDRAM_Init allows the configuration and initialization of the SDRAM.
– CAMERA_Init allows the configuration of the camera module, DCMI registers, and DCMI
parameters.
– One of the two functions HAL_DCMI_Start_DMA allowing the DCMI configuration in snapshot or in
continuous mode, must be uncommented.
/* USER CODE BEGIN 2 */
LTDC_Init(FRAME_BUFFER, 0, 0, 320, 240);
BSP_SDRAM_Init();
CAMERA_Init(CAMERA_R320x240);
HAL_Delay(1000); //Delay for the camera to output correct data
Im_size = 0x9600; //size=320*240*2/4
/* uncomment the following line in case of snapshot mode */
//HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)FRAME_BUFFER, Im_size);
/* uncomment the following line in case of continuous mode */
HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_CONTINUOUS , (uint32_t)FRAME_BUFFER, Im_size);
/* USER CODE END 2 */
3. Insert the implementation of the new functions (called in the main() function), out of the main function, in
the adequate space, indicated in bold below.
/* USER CODE BEGIN 4 */
void LCD_GPIO_Init(LTDC_HandleTypeDef *hltdc, void *Params)
{
GPIO_InitTypeDef gpio_init_structure;
/* Enable the LTDC and DMA2D clocks */
__HAL_RCC_LTDC_CLK_ENABLE();
__HAL_RCC_DMA2D_CLK_ENABLE();
/* Enable GPIOs clock */
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOI_CLK_ENABLE();
__HAL_RCC_GPIOJ_CLK_ENABLE();
__HAL_RCC_GPIOK_CLK_ENABLE();
/*** LTDC Pins configuration ***/
/* GPIOE configuration */
gpio_init_structure.Pin = GPIO_PIN_4;
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FAST;
gpio_init_structure.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOE, &gpio_init_structure);
/* GPIOG configuration */
gpio_init_structure.Pin = GPIO_PIN_12;
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Alternate = GPIO_AF9_LTDC;
HAL_GPIO_Init(GPIOG, &gpio_init_structure);
/* GPIOI LTDC alternate configuration */
gpio_init_structure.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_13 |
GPIO_PIN_14 | GPIO_PIN_15;
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOI, &gpio_init_structure);
/* GPIOJ configuration */
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 |
GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_5
| GPIO_PIN_6 | GPIO_PIN_7 |GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 |
GPIO_PIN_11 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOJ, &gpio_init_structure);
/* GPIOK configuration */
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 |
GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOK, &gpio_init_structure);
/* LCD_DISP GPIO configuration */
gpio_init_structure.Pin = GPIO_PIN_12; /* LCD_DISP pin has to be
manually controlled */
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOI, &gpio_init_structure);
/* LCD_BL_CTRL GPIO configuration */
gpio_init_structure.Pin = GPIO_PIN_3; /* LCD_BL_CTRL pin has to be
manually controlled */
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOK, &gpio_init_structure);
}
static void LTDC_Init(uint32_t FB_Address, uint16_t Xpos, uint16_t Ypos,
uint16_t Width, uint16_t Height)
{
/* Timing Configuration */
hltdc.Init.HorizontalSync = (RK043FN48H_HSYNC - 1);
hltdc.Init.VerticalSync = (RK043FN48H_VSYNC - 1);
hltdc.Init.AccumulatedHBP = (RK043FN48H_HSYNC + RK043FN48H_HBP - 1);
hltdc.Init.AccumulatedVBP = (RK043FN48H_VSYNC + RK043FN48H_VBP - 1);
hltdc.Init.AccumulatedActiveH = (RK043FN48H_HEIGHT + RK043FN48H_VSYNC +
RK043FN48H_VBP - 1);
else
{
status = CAMERA_NOT_SUPPORTED; /* Return CAMERA_NOT_SUPPORTED status */
}
return status;
}
/* USER CODE END 4 */
At this stage, the user can build, debug, and run the project.
1. Add the table containing the configuration of camera module registers in main.c,
below /* Private variables ----------------------*/.
const unsigned char OV9655_YUV_QVGA [ ][2]=
{ { 0x12, 0x80 },{ 0x00, 0x00 },{ 0x01, 0x80 },{ 0x02, 0x80 },{ 0x03, 0x02
},{ 0x04, 0x03 },{ 0x0e, 0x61 }, { 0x0f, 0x42 },{ 0x11, 0x01 },{ 0x12, 0x62
},{ 0x13, 0xe7 },{ 0x14, 0x3a },{ 0x16, 0x24 },{ 0x17, 0x18 }, { 0x18, 0x04
},{ 0x19, 0x01 },{ 0x1a, 0x81 } ,{ 0x1e, 0x04 },{ 0x24, 0x3c },{ 0x25, 0x36
},{ 0x26, 0x72 }, { 0x27, 0x08 },{ 0x28, 0x08 },{ 0x29, 0x15 },{ 0x2a, 0x00
},{ 0x2b, 0x00 },{ 0x2c, 0x08 },{ 0x32, 0x24 }, { 0x33, 0x00 },{ 0x34, 0x3f
},{ 0x35, 0x00 },{ 0x36, 0x3a },{ 0x38, 0x72 },{ 0x39, 0x57 } ,{ 0x3a, 0x0c
},{ 0x3b, 0x04 },{ 0x3d, 0x99 },{ 0x3e, 0x0e },{ 0x3f, 0xc1 },{ 0x40, 0xc0}
,{ 0x41, 0x01 },{ 0x42, 0xc0 },{ 0x43, 0x0a },{ 0x44, 0xf0 },{ 0x45, 0x46
},{ 0x46, 0x62} ,{ 0x47, 0x2a },{ 0x48, 0x3c },{ 0x4a, 0xfc }, { 0x4b, 0xfc
},{ 0x4c, 0x7f },{ 0x4d, 0x7f}, { 0x4e, 0x7f },{ 0x52, 0x28 },{ 0x53, 0x88
},{ 0x54, 0xb0 }, { 0x4f, 0x98 },{ 0x50, 0x98} ,{ 0x51, 0x00 },{ 0x58, 0x1a
},{ 0x59, 0x85 },{ 0x5a, 0xa9 },{ 0x5b, 0x64 } ,{ 0x5c, 0x84 },{ 0x5d, 0x53
},{ 0x5e, 0x0e },{ 0x5f, 0xf0 },{ 0x60, 0xf0 },{ 0x61, 0xf0 } ,{ 0x62, 0x00
}, { 0x63, 0x00 },{ 0x64, 0x02 },{ 0x65, 0x20 },{ 0x66, 0x00 },{ 0x69, 0x0a
},{ 0x6b, 0x5a },{ 0x6c, 0x04 }, { 0x6d, 0x55 },{ 0x6e, 0x00 },{ 0x6f, 0x9d
},{ 0x70, 0x21 },{ 0x71, 0x78 },{ 0x72, 0x11 },{ 0x73, 0x01 }, { 0x74, 0x10
},{ 0x75, 0x10 } ,{ 0x76, 0x01 },{ 0x77, 0x02 },{ 0x7a, 0x12 },{ 0x7b, 0x08
},{ 0x7c, 0x15 }, { 0x7d, 0x24 },{ 0x7e, 0x45 },{ 0x7f, 0x55 },{ 0x80, 0x6a
},{ 0x81, 0x78 },{ 0x82, 0x87 },{ 0x83, 0x96 }, { 0x84, 0xa3 },{ 0x85, 0xb4
},{ 0x86, 0xc3 },{ 0x87, 0xd6 },{ 0x88, 0xe6 } ,{ 0x89, 0xf2 },{ 0x8a, 0x24
}, { 0x8c, 0x80 },{ 0x90, 0x7d },{ 0x91, 0x7b },{ 0x9d, 0x02 } ,{ 0x9e, 0x02
},{ 0x9f, 0x7a },{ 0xa0, 0x79 }, { 0xa1, 0x40 },{ 0xa4, 0x50 },{ 0xa5, 0x68
},{ 0xa6, 0x4a },{ 0xa8, 0xc1 },{ 0xa9, 0xef },{ 0xaa, 0x92 }, { 0xab, 0x04
} ,{ 0xac, 0x80 },{ 0xad, 0x80 },{ 0xae, 0x80 },{ 0xaf, 0x80 },{ 0xb2, 0xf2
},{ 0xb3, 0x20 } ,{ 0xb4, 0x20 },{ 0xb5, 0x00 },{ 0xb6, 0xaf },{ 0xbb, 0xae
},{ 0xbc, 0x7f },{ 0xbd, 0x7f } ,{ 0xbe, 0x7f },{ 0xbf, 0x7f },{ 0xc0, 0xaa
},{ 0xc1, 0xc0 },{ 0xc2, 0x01 },{ 0xc3, 0x4e } ,{ 0xc6, 0x05 },{ 0xc7, 0x81
},{ 0xc9, 0xe0 },{ 0xca, 0xe8 },{ 0xcb, 0xf0 },{ 0xcc, 0xd8 } ,{ 0xcd, 0x93
}, { 0xcd, 0x93 },{ 0xFF, 0xFF } };
2. The new function prototype has to be inserted below /* Private function prototypes ------*/.
void OV9655_YUV_Init (uint16_t );
3. The second step of modifications in main.c described in Section 8.3.2.8 has to be updated. Modify
the main() function by inserting the following functions in the adequate space, indicated in bold below.
One of the two functions allowing the DCMI configuration in snapshot or in continuous mode must be
uncommented.
/* USER CODE BEGIN 2 */
BSP_SDRAM_Init();
CAMERA_Init(CameraHwAddress);
OV9655_YUV_Init(CameraHwAddress);
HAL_Delay(1000); //Delay for the camera to output correct data
Im_size = 0x9600; //size=320*240*2/4
/* uncomment the following line in case of snapshot mode */
//HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)FRAME_BUFFER, Im_size);
/* uncomment the following line in case of continuous mode */
HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_CONTINUOUS , (uint32_t)FRAME_BUFFER, Im_size);
/* USER CODE END 2 */
4. The third step of modifications in main.c described in Section 8.3.2.8 has to be updated by adding the
new function implementation.
void OV9655_YUV_Init(uint16_t DeviceAddr)
{ uint32_t index;
for(index=0; index<(sizeof(OV9655_YUV_QVGA)/2); index++)
{ CAMERA_IO_Write(DeviceAddr, OV9655_YUV_QVGA[index][0],
OV9655_YUV_QVGA[index][1]);
CAMERA_Delay(1);
} }
DMA configuration
The DMA is configured as described in Section 6.4.9 DMA configuration for higher resolutions. The
HAL_DMA_START function ensures this configuration because the image size exceeds the maximum allowed
size for double-buffer mode.
Calling HAL_DMA_START ensures the division of the received frames to equal parts, and the placement of each
part in one frame buffer. As explained, for the SXGA resolution, each frame is divided in 16 frame buffers. Each
buffer size is equal to 40960 words.
For the buffers addresses, HAL_DMA_START ensures the placement of the 16 frame buffers in the memory. In this
case, the address of the first frame buffer is 0xC0000000. The second address is then 0xC0163840 (0xC0000000
+ (40960 * 4)). The 16th frame buffer address is (0xC0000000 + 16 * (40960 * 4)).
Each end of transfer, the DMA has filled one frame, an interrupt is generated, the address of the next buffer is
calculated, and one pointer is modified as illustrated in Figure 47. DMA operation in high resolution case.
To ensure that the camera module sends image having a YCbCr format, the CMOS sensor registers must be
configured with the following steps:
1. Add the table containing the configuration of camera module registers in main.c
below /* Private variables -------------------------*/.
const unsigned char ov9655_yuv_sxga[][2]= {
{ 0x12, 0x80 },{ 0x00, 0x00 },{ 0x01, 0x80 },{ 0x02, 0x80 },{ 0x03, 0x1b },{
0x04, 0x03 }, { 0x0e, 0x61 },{ 0x0f, 0x42 },{ 0x11, 0x00 },{ 0x12, 0x02 },{
0x13, 0xe7 },{ 0x14, 0x3a },{ 0x16, 0x24 }, { 0x17, 0x1d },{ 0x18, 0xbd },{
0x19, 0x01 },{ 0x1a, 0x81 }, { 0x1e, 0x04 }, { 0x24, 0x3c }, { 0x25, 0x36
},{ 0x26, 0x72 }, { 0x27, 0x08 }, { 0x28, 0x08 },{ 0x29, 0x15 },{ 0x2a, 0x00
},{ 0x2b, 0x00 },{ 0x2c, 0x08 },{ 0x32, 0xff },{ 0x33, 0x00 },{ 0x34, 0x3d
},{ 0x35, 0x00 },{ 0x36, 0xf8 },{ 0x38, 0x72 },{ 0x39, 0x57 }, { 0x3a, 0x0c
},{ 0x3b, 0x04 },{ 0x3d, 0x99 }, { 0x3e, 0x0c },{ 0x3f, 0xc1 },{ 0x40, 0xd0
},{ 0x41, 0x00 },{ 0x42, 0xc0 },{ 0x43, 0x0a },{ 0x44, 0xf0 },{ 0x45, 0x46
},{ 0x46, 0x62 }, { 0x47, 0x2a }, { 0x48, 0x3c },{ 0x4a, 0xfc },{ 0x4b, 0xfc
},{ 0x4c, 0x7f },{ 0x4d, 0x7f },{ 0x4e, 0x7f },{ 0x52, 0x28 },{ 0x53, 0x88
},{ 0x54, 0xb0 },{ 0x4f, 0x98 },{ 0x50, 0x98 },{ 0x51, 0x00 },{ 0x58, 0x1a
},{ 0x58, 0x1a },{ 0x59, 0x85 },{ 0x5a, 0xa9 },{ 0x5b, 0x64 },{ 0x5c, 0x84
},{ 0x5d, 0x53 },{ 0x5e, 0x0e }, { 0x5f, 0xf0 }, { 0x60, 0xf0 }, { 0x61,
0xf0 },{ 0x62, 0x00 }, { 0x63, 0x00 }, { 0x64, 0x02 },{ 0x65, 0x16 },{ 0x66,
0x01 },{ 0x69, 0x02 },{ 0x6b, 0x5a }, { 0x6c, 0x04 }, { 0x6d, 0x55 }, {
0x6e, 0x00 },{ 0x6f, 0x9d },{ 0x70, 0x21 }, { 0x71, 0x78 },{ 0x72, 0x00 },{
0x73, 0x01 },{ 0x74, 0x3a },{ 0x75, 0x35 },{ 0x76, 0x01 },{ 0x77, 0x02 },{
0x7a, 0x12 },{ 0x7b, 0x08 }, { 0x7c, 0x15 }, { 0x7d, 0x24 },{ 0x7e, 0x45 },{
0x7f, 0x55 },{ 0x80, 0x6a },{ 0x81, 0x78 },{ 0x82, 0x87 },{ 0x83, 0x96 },{
0x84, 0xa3 },{ 0x85, 0xb4 }, { 0x86, 0xc3 },{ 0x87, 0xd6 },{ 0x88, 0xe6 },
{ 0x89, 0xf2 },{ 0x8a, 0x03 }, { 0x8c, 0x0d }, { 0x90, 0x7d }, { 0x91, 0x7b
}, { 0x9d, 0x03 },{ 0x9e, 0x04 }, { 0x9f, 0x7a }, { 0xa0, 0x79 }, { 0xa1,
0x40 }, { 0xa4, 0x50 },{ 0xa5, 0x68 }, { 0xa6, 0x4a }, { 0xa8, 0xc1 },{
0xa9, 0xef }, { 0xaa, 0x92 },{ 0xab, 0x04 },{ 0xac, 0x80 },{ 0xad, 0x80 },{
0xae, 0x80 },{ 0xaf, 0x80 },{ 0xb2, 0xf2 },{ 0xb3, 0x20 },{ 0xb4, 0x20 },{
0xb5, 0x00 },{ 0xb6, 0xaf },{ 0xbb, 0xae },{ 0xbc, 0x7f },{ 0xbd, 0x7f },{
0xbe, 0x7f }, { 0xbf, 0x7f },{ 0xc0, 0xe2 },{ 0xc1, 0xc0 },{ 0xc2, 0x01 },
{ 0xc3, 0x4e }, { 0xc6, 0x05 },{ 0xc7, 0x80 }, { 0xc9, 0xe0 },{ 0xca, 0xe8
}, { 0xcb, 0xf0 },{ 0xcc, 0xd8 },{0xcd, 0x93} ,{ 0xFF, 0xFF } };
3. The second step of modifications in main.c in this example is to update the main() function by inserting
the following functions in the adequate space (indicated in bold below). One of the two functions allowing
the DCMI configuration in snapshot or in continuous mode must be uncommented.
/* USER CODE BEGIN 2 */
BSP_SDRAM_Init();
CAMERA_Init(CameraHwAddress);
OV9655_YUV_Init(CameraHwAddress);
HAL_Delay(1000); //Delay for the camera to output correct data
Im_size = 0xA0000; //size=1280*1024*2/4
/* uncomment the following line in case of snapshot mode */
//HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)FRAME_BUFFER,
Im_size);
/* uncomment the following line in case of continuous mode */
HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_CONTINUOUS , (uint32_t)FRAME_BUFFER,
Im_size);
/* USER CODE END 2 */
4. The third step of modifications in main.c described in Section 8.3.2.8 has to be updated by adding the
new function implementation below /* USER CODE BEGIN 4 */ .
void OV9655_YUV_Init(uint16_t DeviceAddr)
{
uint32_t index;
for(index=0; index<(sizeof(ov9655_yuv_sxga)/2); index++)
{
CAMERA_IO_Write(DeviceAddr, ov9655_yuv_sxga[index][0],
ov9655_yuv_sxga[index][1]);
CAMERA_Delay(1);
}
}
Note: In case of frame with RGB data format, the user can reduce the resolution to display the received images on the
LCD_TFT by using the resizing feature of the DCMI.
DCMI configuration
The DCMI needs to be configured to receive compressed data (JPEG) by setting the JPEG bit in DCMI_CR.
To set this bit, the user must simply add the instruction written in bold below in the stm324x9i_eval_camera.
c file in uint8_t BSP_CAMERA_Init(uint32_t Resolution) (this function is called in main() to configure
the DCMI and the camera module). The DCMI previous configuration is kept.
phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME;
phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_LOW;
phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_LOW;
phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
phdcmi->Init.JPEGMode = DCMI_JPEG_ENABLE;
To modify the camera module registers, the previous table must be sent to the camera through the I2C. In ov264
0.c, in void ov2640_Init(uint16_t DeviceAddr, uint32_t resolution), replace:
case CAMERA_R320x240:
{
for(index=0; index<(sizeof(OV2640_QVGA)/2); index++)
{
CAMERA_IO_Write(DeviceAddr, OV2640_QVGA[index][0],
OV2640_QVGA[index][1]);
CAMERA_Delay(1);
}
break;
}
by
case CAMERA_R320x240:
{
for(index=0; index<(sizeof( OV2640_JPEG)/2); index++)
{
CAMERA_IO_Write(DeviceAddr, OV2640_JPEG[index][0],
OV2640_JPEG[index][1]);
CAMERA_Delay(1);
}
break;
}
9 Supported devices
To know if a CMOS sensor (a camera module) is compatible with the DCMI or not, the user must check the
following points in the CMOS sensor specifications:
• parallel interface (8-, 10-, 12-, or 14-bit)
• control signals (VSYNC, HSYNC, and PIXCLK)
• supported pixel clock frequency output
• supported data output
There is a wide range of camera modules and CMOS sensors that are compatible with the STM32 DCMI.
The table below lists some of them.
10 Conclusion
The DCMI represents an efficient interface to connect the camera modules to the STM32 MCUs supporting high
speed, high resolutions, and a variety of data formats/widths.
Together with the variety of peripherals and interfaces integrated in STM32 MCUs and benefiting from the STM32
smart architecture, the DCMI can be used in large and sophisticated imaging applications.
This application note covers the DCMI across the STM32 MCUs, providing all the necessary information to
correctly use the DCMI, and to succeed in implementing applications starting from the compatible camera module
selection to detailed examples implementation.
Revision history
Table 16. Document revision history
Contents
1 General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Camera modules and basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1 Imaging basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Camera module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2.1 Camera module components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2.2 Camera module interconnect (parallel interface) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 STM32 DCMI overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 DCMI availability and features across STM32 MCUs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 DCMI in a smart architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1 STM32F2 system architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.2 STM32F4 system architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.3 STM32F7 system architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.4 STM32H7 system architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.5 STM32L4 system architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.6 STM32L4+ system architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2.7 STM32U5 system architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2.8 STM32H5 system architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4 Reference boards with DCMI and/or camera modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
5 DCMI description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
5.1 Hardware interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 Camera module and DCMI interconnection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.3 DCMI functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.4 Data synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.4.1 Hardware (or external) synchronization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.4.2 Embedded (or internal) synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.5 Capture modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.5.1 Snapshot mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.5.2 Continuous grab mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.6 Data formats and storage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.6.1 Monochrome . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.6.2 RGB565 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.6.3 YCbCr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.6.4 YCbCr, Y only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.6.5 JPEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.7 Crop feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
List of tables
Table 1. Applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .... 1
Table 2. DCMI and related resources availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .... 6
Table 3. SRAM availability in STM32F4 Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 4. SRAM availability in STM32H723/733, STM32H743/753, STM32H742, STM32H725/735, STM32H730, and
STM32H750 devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Table 5. SRAM availability in STM32U5 devices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 6. DCMI and camera modules on STM32 boards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Table 7. DCMI operation in low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Table 8. DMA stream selection across STM32 devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Table 9. DMA stream selection across STM32 devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Table 10. Maximum number of bytes transferred during one DMA transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Table 11. Maximum image resolution in normal mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Table 12. Maximum image resolution in double-buffer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Table 13. Maximum data flow at maximum DCMI_PIXCLK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Table 14. STM32Cube DCMI examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Table 15. Examples of supported camera modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Table 16. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
List of figures
Figure 1. Original versus digital image. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Figure 2. Horizontal blanking illustration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Figure 3. Vertical blanking illustration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Figure 4. Camera module examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Figure 5. Interfacing a camera module with an STM32 MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 6. DCMI slave AHB2 peripheral in STM32F2x7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 7. DCMI slave AHB2 peripheral in STM32F4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 8. DCMI slave AHB2 peripheral in STM32F7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 9. DCMI slave AHB2 peripheral in STM32H723/733, STM32H743/753, STM32H742, STM32H725/735,
STM32H730, and STM32H750 devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 10. DCMI slave AHB2 peripheral in STM32H745/755 and STM32H747/757 devices . . . . . . . . . . . . . . . . . . . . . 14
Figure 11. DCMI slave AHB2 peripheral in STM32H7A3/B3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 12. DCMI slave AHB2 peripheral in STM32L496/4A6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 13. DCMI slave AHB2 peripheral in STM32L4+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 14. DCMI slave AHB2 peripheral in STM32U5 devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Figure 15. DCMI slave AHB2 peripheral in STM32H562 and STM32H563/573. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Figure 16. DCMI signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Figure 17. DCMI block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Figure 18. Data register filled for 8-bit data width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Figure 19. Data register filled for 10-bit data width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Figure 20. Data register filled for 12-bit data width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Figure 21. Data register filled for 14-bit data width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Figure 22. STM32 MCU and camera module interconnection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Figure 23. Frame structure in hardware synchronization mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Figure 24. Embedded code bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Figure 25. Frame structure in embedded synchronization mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Figure 26. Frame structure in embedded synchronization mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Figure 27. Embedded code unmasking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Figure 28. Frame reception in snapshot mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Figure 29. Frame reception in continuous grab mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Figure 30. Pixel raster scan order. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Figure 31. DCMI data register filled with monochrome data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Figure 32. DCMI data register filled with RGB data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Figure 33. DCMI data register filled with YCbCr data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Figure 34. DCMI data register filled with Y only data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Figure 35. JPEG data reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Figure 36. Frame resolution modification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Figure 37. DCMI interrupts and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Figure 38. DCMI_ESCR register bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Figure 39. FEC structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Figure 40. LEC structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Figure 41. FSC structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Figure 42. LSC structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Figure 43. Frame structure in embedded synchronization mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Figure 44. Data transfer through the DMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Figure 45. Frame buffer and DMA_SxNDTR register in circular mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Figure 46. Frame buffer and DMA_SxNDTR register in double-buffer mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Figure 47. DMA operation in high resolution case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Figure 48. STM32 DCMI application example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Figure 49. Data path in capture and display application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Figure 50. 32F746GDISCOVERY and STM32F4DIS-CAM interconnection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Figure 51. Camera connector on 32F746GDISCOVERY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Figure 52. Camera connector on STM32F4DIS-CAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57