You point a microcontroller camera board at 640 × 480 and get a refusal or a scrambled image, while 320 × 240 runs all day. The camera is almost never the limit; the framebuffer is. The arithmetic below tells you, before you write any code, whether a resolution fits your board: the bytes per frame for each pixel format, the RAM a double-buffered capture really needs, and the cache discipline that makes an external-SDRAM framebuffer deliver clean frames every time. It ends with the decision for each case: halve the format, move the buffer, or move the capture off the board.
The buffer, not the sensor, stops capture at QVGA
A sensor with a parallel interface will clock out 640 × 480 whenever its mode list says so; the limit you hit is residency. Every captured frame must land in a region the capture hardware can write and your code can read, and that region must stay undisturbed for the whole frame.
On microcontroller-class boards that region competes with everything else in internal SRAM: stack, heap, the display framebuffer, library statics. The budget that matters is the largest free contiguous block, not the RAM figure printed on the box — the same budget the Out of fast frame buffer memory: fit algorithms to embedded RAM guide works through. A QVGA frame in RGB565 needs 153,600 bytes, 150 KiB, and that fits what is left over on many boards. A VGA frame in the same format needs 614,400 bytes, 600 KiB — four times as much, and more than any single free block on these boards. That jump, not a sensor limit, is why the example sketches you find stop at QVGA.
If you are still choosing a board rather than fighting one you own, apply this budget before you buy: a beginner's guide to choosing a first development board walks the selection question from the start.
The byte budget: width × height × bytes per pixel
The whole decision is one multiplication:
RGB565 stores a pixel in 2 bytes, RGB888 in 3, and 8-bit Bayer or mono in 1. Worked out for the three resolutions in this range:
| Resolution | Pixels | 8-bit Bayer or mono (1 B/px) | RGB565 (2 B/px) | RGB888 (3 B/px) |
|---|---|---|---|---|
| QVGA 320 × 240 | 76,800 | 76,800 B (75 KiB) | 153,600 B (150 KiB) | 230,400 B (225 KiB) |
| VGA 640 × 480 | 307,200 | 307,200 B (300 KiB) | 614,400 B (600 KiB) | 921,600 B (900 KiB) |
| SVGA 800 × 600 | 480,000 | 480,000 B (468.75 KiB) | 960,000 B (937.5 KiB) | 1,440,000 B (1.37 MiB) |
Three adjustments before you trust the table. Double the frame figure if you ping-pong buffers so you can process one frame while the next arrives. Watch for drivers that round the width up to an alignment boundary before sizing the buffer — the multiples-of-16 alignment and crop rule explains where those extra bytes come from. And treat a resolution and a pixel format as one pair: a camera library exposes a fixed list of pairs per module, and VGA in RGB565 may not exist on your module even though the sensor can output VGA. Check the pair list first, because no amount of RAM tuning creates a missing format.
Worked example: 640 × 480 VGA in RGB565 on a microcontroller board
Inputs. Width 640, height 480 — the VGA target, one step above the 320 × 240 that already runs. Two bytes per pixel — the RGB565 format definition. Board behaviour, from the case this guide targets: QVGA in RGB565 runs from internal SRAM, so the largest free block there is at least 150 KiB, and VGA fails in internal SRAM, so that block is below 600 KiB. External SDRAM is fitted and measures in megabytes.
Rule. A resolution fits in a memory region only when the region's largest free block is at least width × height × bytes per pixel — twice that for a double-buffered capture.
Arithmetic. Pixels per VGA frame: 640 × 480 = 307,200. In RGB565: 307,200 × 2 = 614,400 bytes = 600 KiB. The running QVGA frame for comparison: 320 × 240 × 2 = 153,600 bytes = 150 KiB, and 614,400 ÷ 153,600 = 4× the demand. The 8-bit Bayer alternative: 307,200 × 1 = 307,200 bytes = 300 KiB. Full-colour RGB888: 307,200 × 3 = 921,600 bytes = 900 KiB. Double-buffered RGB565: 2 × 614,400 = 1,228,800 bytes = 1.17 MiB.
Result. Internal SRAM cannot hold one VGA RGB565 frame, let alone two: its largest free block sits between 150 and 600 KiB while the single frame alone needs 600 KiB. The SDRAM holds it easily — 1 MB leaves 1,048,576 − 614,400 = 434,176 bytes spare around one frame, and a 2 MB part holds the 1,228,800-byte ping-pong pair with room for scratch memory.
Decision. With more than 600 KiB of largest free block, keep the framebuffer in internal SRAM and skip cache maintenance entirely. Between 300 and 600 KiB, switch the format: 8-bit Bayer fits one VGA frame internally. Below 300 KiB, move the buffer to external SDRAM with per-frame cache maintenance, or move capture to a streaming camera. Bandwidth is not the binding constraint at this size: at 30 fps the RGB565 stream is 614,400 × 30 = 18,432,000 bytes per second, about 18.4 MB/s, which external SDRAM sustains without effort.
External SDRAM works when you maintain the cache per frame
Move the framebuffer to SDRAM and a second failure mode appears, and it produces exactly the symptom behind so many stuck-at-QVGA projects: some frames arrive clean, others are torn, and at VGA the display is garbage almost always. The capture hardware writes SDRAM directly, bypassing the CPU's data cache. Two things then go wrong. The CPU reads cache lines that predate the transfer, so it sees stale pixels. Worse, dirty lines near the buffer get evicted and written back to SDRAM while the frame is still arriving, overwriting incoming data — that is what tears an image into horizontal shards.
A single whole-cache call such as SCB_CleanInvalidateDCache() cannot fix this, because it races with the transfer: whatever it cleans or invalidates, the cache fills and evicts lines again while DMA is still writing. Maintenance has to cover exactly the capture buffer, at the right moment, on every frame:
- Place each capture buffer at a cache-line boundary — 32 bytes on Cortex-M7-class cores — and round its length up to a whole number of lines, so maintenance on the buffer never touches neighbouring variables.
- On the frame-complete interrupt, invalidate the data cache over exactly that address range, then read or convert the pixels.
- When the CPU writes a buffer the DMA will read, clean that same range before the transfer starts.
- Repeat every frame. Cache maintenance is per-transfer, like the copy-before-reuse discipline in push the camera buffer back only after copying your frame data, not a start-up setting.
Some boards let you mark the SDRAM region non-cacheable for DMA. That removes maintenance entirely and is the simplest reliable arrangement for capture-and-forward designs; in-place processing then runs slower because every CPU access goes to SDRAM.
Halve the buffer: capture raw Bayer, convert as lines arrive
The cheapest fix is the format. Raw 8-bit Bayer uses one byte per pixel, so VGA drops from 614,400 to 307,200 bytes and SVGA from 960,000 to 480,000 — half the RAM at every resolution in the table. If the frames feed processing or a host, Bayer is what you want anyway: the Bayer colour camera decision checklist covers when colour reconstruction earns its keep, and grayscale for machine learning works the same halving from the pixel side.
If a colour display on the board is the endpoint, you still never need a second full-size RGB buffer: demosaic each line into the display framebuffer as it arrives, and peak memory stays at one Bayer frame plus the display's own memory. One check first: some sensor and library combinations produce Bayer only at particular resolutions, so confirm the VGA-plus-Bayer pair exists in your module's format list before you plan around it.
When the board is the limit: move capture to a streaming camera
If the product needs VGA or above, at useful frame rates, with real processing, the arithmetic says the platform is wrong, not the code. A streaming camera moves the frame off your board: pixels travel over USB3 or GigE into host memory measured in hundreds of megabytes, and your code receives complete frames. The framebuffer constraint disappears, and the cache problem goes with it, because the receiving driver owns that job.
Board-level cameras exist to be built into your own device, and the bare-board kind ships with no housing at all.
- Sensor format
- 1/1.8"
- Interface
- USB3
- Resolution
- 6-10 MP
- Shutter
- Rolling
The MV-CB060-10UM-B is a 6 MP mono bare-board camera on USB3 with a 1/1.8-inch sensor. The LS-BCM-0003 is a 3.1 MP USB3 board camera with a 1/1.8-inch global shutter and a C-mount, streaming at up to 120 fps. The LS-BCM-0056 is a 12 MP GigE board camera with a C-mount and 1.6 μm × 1.6 μm pixels.
- Sensor format
- 1/1.8"
- Lens mount
- C-mount
- Sensor format
- 1/2"
- Lens mount
- C-mount
A 12 MP frame in 8-bit mono is roughly 12,000,000 bytes, about twenty VGA RGB565 frames, and a host absorbs that without noticing. For a housed camera with a standard lens mount instead of an open board, the area scan camera catalog covers GigE and USB3 in metal. To shortlist by sensor, mount and interface, start at the camera finder.
Checks before you commit
- Compute the budget from the real format pair: width × height × bytes per pixel, × 2 if you double-buffer, and compare it with the largest free block, not total RAM.
- Confirm the resolution-and-format pair exists in your module's format list. If Bayer at VGA is missing, the plan changes before a line of code is written.
- Align each capture buffer to a 32-byte cache line and round its length up to whole lines.
- Soak-test with a checksum: capture a fixed test pattern for a few thousand frames and compare every frame's checksum. Coherency and alignment faults appear as mismatches long before they appear reliably to the eye.
- Multiply the bandwidth too: VGA RGB565 at 30 fps is 614,400 × 30 = 18,432,000 bytes per second. If the camera hangs off an SPI bus instead of parallel, the transfer itself can exceed the frame period — sizing a frame transfer over SPI works that budget.
- When the display is smaller than the frame, decimate or crop during transfer and keep the capture buffer whole; downscaling after capture covers the trade-offs.
The decision, case by case
- Largest free block above 600 KiB: capture RGB565 in internal SRAM, no cache work needed.
- Between 300 and 600 KiB: capture 8-bit Bayer at the target resolution, or stay at QVGA in RGB565.
- SDRAM fitted and internal RAM short: put the buffers in SDRAM, aligned to 32-byte lines, with invalidate-on-frame-complete and clean-before-DMA-read as a routine, every frame.
- Target above SVGA, or heavy processing at VGA: step up to a streaming camera into host memory. The board-level cameras start that move at board scale, the camera configurator builds it into a system, and more capture-side guides sit on the cameras topic page.
Questions
Do I need twice the buffer if I capture while processing?
Yes. Ping-pong capture holds two frames, so VGA in RGB565 needs 2 × 614,400 = 1,228,800 bytes, about 1.17 MiB; in 8-bit Bayer the pair needs 614,400 bytes total. If two frames cannot fit, convert or process inside the frame-complete callback before the next frame's first line arrives, or lower the frame rate so processing always finishes within one frame period.
Can I show a VGA frame on a 320 × 240 display without a second buffer?
Decimate during the copy: take every second pixel and every second line and the display framebuffer receives 76,800 pixels while the capture buffer still holds all 307,200 pixels of the VGA frame. Decimation cuts display and processing work; it does not shrink the capture buffer. Only capture-side binning or a lower sensor mode makes the buffer itself smaller.
Does a JPEG-capable camera module remove the RAM problem?
It can. When the module compresses internally, the board stores compressed bytes only: at a typical 10:1 JPEG ratio a VGA frame drops from 614,400 bytes to about 61 KB. You trade away lossless pixels for measurement, add decompression work at the receiving end, and inherit the module's limits — many output JPEG only at a few fixed resolutions, so check the format list first.
What if my capture driver pads each line to a boundary?
Budget with the stride, not the width. VGA in RGB565 is 640 × 2 = 1,280 bytes per line; if the driver rounds each line to a 64-byte boundary the stride becomes 1,344 bytes and the frame occupies 480 × 1,344 = 645,120 bytes instead of 614,400. Read the stride from the driver's format description before you size anything.
Is 320 × 240 QVGA or SVGA?
QVGA is 320 × 240, one quarter of VGA's 640 × 480 pixel count; SVGA is 800 × 600. Menus and example sketches sometimes label 320 × 240 as SVGA, which is how the two get confused. Trust the pixel dimensions in the format entry — the buffer arithmetic uses numbers, not names.


