STM32H750 DCMI JPEG Capture: Separate Compressed Bytes from DMA Words
The STM32H750 DCMI receives a camera’s compressed JPEG byte stream; it does not decode that stream into pixels. Its DMA-facing packing also means that the byte capacity occupied by those DMA words can exceed the valid JPEG byte count. Treat frame capture, storage occupancy and compressed payload length as separate pieces of evidence.
This guide uses RM0433 Rev 9 and AN5020 Rev 4, November 2024. It concerns an already configured JPEG-output camera using hardware synchronization. No camera capture, DMA driver or JPEG decoder was executed for this article.
Establish the camera’s JPEG wire contract
In RM0433 section 31.3.9, setting DCMI_CR.JPEG enables reception of JPEG-formatted data. VSYNC participates in frame capture and HSYNC acts as data enable. Match their polarities and the sampling edge to the actual camera output; a signal named HSYNC is not a guarantee that compressed data arrives as fixed-width raster rows.
Record how the selected sensor marks a frame and whether its documented output includes any wrapper or non-image bytes. DCMI cannot infer that contract from a requested image width. A compression setting or changed scene can alter stream length even when the image dimensions remain the same.
The reference manual prohibits crop and embedded synchronization in JPEG mode. Do not adapt an uncompressed capture routine by discarding every other byte or selecting a rectangular DCMI crop window. Such operations do not produce a smaller valid compressed image.

Keep three counts in the capture record
Buffer capacity is the memory reserved for reception. DMA words written describe transferred storage units under the configured transfer arrangement. Valid compressed bytes describe the bounded stream that can be handed to its next consumer. None of these counts should silently replace the others.
RM0433 explains that DCMI requests DMA when a 32-bit word is complete. At a detected end of frame, a partial final word is padded with zeros and transferred. Padding completes the storage word; it does not extend the camera’s JPEG payload.
For a hypothetical 13-byte payload, packing requires four words, occupying 16 bytes with three final padding bytes. This is arithmetic only, not a real JPEG file or measured capture. The same four-word count could cover different valid byte counts, so word occupancy alone cannot recover the precise payload length.
Do not remove arbitrary trailing zeros as a universal length algorithm. Determine the valid extent through the camera protocol and an appropriate bounded JPEG/container validation path. That path must distinguish legitimate stream bytes from transport padding and must never scan beyond the captured allocation.
Observe frame completion and transfer state independently
AN5020’s capture-mode discussion describes snapshot reception of one frame. RM0433’s DCMI_CR description states that snapshot clears CAPTURE at the frame’s end. These are capture-state facts, not a universal promise that any particular HAL callback supplies an exact compressed-byte count.
Review the deployed DMA and HAL implementation before interpreting counters or completion callbacks. A reserved DMA transfer length is capacity planning; a frame event reports a different boundary. Account for final-word handling and the driver’s transfer arrangement before handing buffer ownership to a consumer.
Keep DCMI overrun and synchronization errors with the frame record. RM0433 describes FIFO reset and waiting for a new start of frame after overrun or synchronization error. A later frame event must not rehabilitate an earlier partial buffer by accident. Maintain a clear association between the captured bytes and the frame being accepted.
Define bounded failure handling
A missing end-of-frame signal needs an application-defined timeout and recovery plan based on the selected sensor and driver. Do not infer an automatic missing-VSYNC timeout from the JPEG padding description: the reference manual ties partial-word padding to detected frame end.
Plan how capture stops when the allocated capacity is exhausted, how an incomplete stream is rejected, and when storage can be reused. Those decisions should be resolved before testing highly detailed scenes or the sensor’s largest supported compressed output.
For qualification, capture several documented camera modes and compare the accepted byte extent with an independent decoder or protocol-aware reference. Include lengths on either side of a four-byte boundary, a deliberately incomplete frame in an isolated fixture, and overrun reporting. All are proposed checks. The result should establish a valid compressed stream with a defensible length before any later JPEG decoding or RGB conversion is considered.