Skip to content

Conversation

@sfe-SparkFro
Copy link
Collaborator

@sfe-SparkFro sfe-SparkFro commented Nov 19, 2025

Fixes #1

Some cameras, like the OV5640, output rows of pixels in very short bursts, with long gaps between each row. Below is an example, where the green trace is the HSYNC signal (high during each row burst):

image

Although the average data rate is easily handled by the QSPI bus, each row burst can be faster than the max QSPI bus rate. I had previously thought the XIP cache would buffer the data by itself, but apparently not, resulting in missed data:

image

This changes the driver to buffer each row of pixels in SRAM, then have another DMA slowly send the row to PSRAM using a control block architecture, similar to the HSTX DVI driver:

image

Now the driver can capture clean images from the OV5640 at 30 FPS:

image

Also seems to fix #2, possibly because this no longer uses interrupts.

Fixes #1
Now buffers each row of pixels in SRAM if needed. DMA setup is similar to HSTX DVI driver
@sfe-SparkFro sfe-SparkFro linked an issue Nov 19, 2025 that may be closed by this pull request
20MHz XCLK results in 30MHz PCLK, which the PIO can just barely handle (37.5MHz max).
25MHz XCLK results in 40MHz PCLK, which is too fast.
Could also change PLL settings, but this is simpler.
@sfe-SparkFro sfe-SparkFro linked an issue Nov 19, 2025 that may be closed by this pull request
Copy link
Member

@gigapod gigapod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I don't see anything that needs changing.

The only possible nit would be changing some of the hard coded numbers (constants, memory sizes ...etc) to actual named constants not "magic numbers", but really nothing to worry about.

Copy link

@malcolm-sparkfun malcolm-sparkfun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

There are some edge-case issues with having the DMAs automatically
capture every frame from the camera. This change makes it default to
non-continuous mode, but users can enable it if they really want.
@sfe-SparkFro sfe-SparkFro merged commit 988c317 into develop Nov 25, 2025
@sfe-SparkFro sfe-SparkFro deleted the rp2_dvp_pio branch November 25, 2025 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RP2 DVP PIO driver consumes memory for some reason: RP2350 can't capture OV5640 data at full speed

4 participants