RepositoryCPLPoland
SI

SimpleMethod/STM32-OV2640

Probably the best library for OV2640 camera on STM32 platform

152stars
23forks
4issues
3views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: dcmi

#1 Repository of the week

1
TINIX TRENDING·Topic: stm32f767zi

#1 Repository of the week

1
TINIX TRENDING·Topic: dma

#1 Repository of the week

Fully implementation library support OV2640 camera on STM32 platform

POC

🚀 Features

Support for resolutions:

  • 160X120px,
  • 320X240px,
  • 640X480px,
  • 800x600px,
  • 1024x768px,
  • 1280x960px,

Added support for extra special effects:

  • brightness,
  • saturation,
  • contrast,
  • light mode,
  • special effect such as: antique, bluish, greenish, reddish, black & white style, negative, Negative with black & white style and normal view.

Support for libjpeg library. Branch with example: https://github.com/SimpleMethod/STM32-OV2640/tree/Imageoptimization

Code optimization, now requires 10 times less space in buffer than before!

📚 Documentation

Pin configuration:

PERIPHERALSMODESFUNCTIONSPINS
DCMISlave 8 bits External SynchroDCMI_D0PC6
DCMISlave 8 bits External SynchroDCMI_D1PC7
DCMISlave 8 bits External SynchroDCMI_D2PC8
DCMISlave 8 bits External SynchroDCMI_D3PC9
DCMISlave 8 bits External SynchroDCMI_D4PE4
DCMISlave 8 bits External SynchroDCMI_D5PD3
DCMISlave 8 bits External SynchroDCMI_D6PE5
DCMISlave 8 bits External SynchroDCMI_D7PE6
DCMISlave 8 bits External SynchroDCMI_HSYNCPA4
DCMISlave 8 bits External SynchroDCMI_PIXCLKPA6
DCMISlave 8 bits External SynchroDCMI_VSYNCPG9
I2C1I2CI2C1_SCLPB8
I2C1I2CI2C1_SDAPB9
RCCBYPASS Clock SourceRCC_OSC_INPH0/OSC_IN
RCCBYPASS Clock SourceRCC_OSC_OUTPH1/OSC_OUT
RCCCrystal/Ceramic ResonatorRCC_OSC32_INPC14/OSC32_IN
RCCCrystal/Ceramic ResonatorRCC_OSC32_OUTPC15/OSC32_OUT
RCCClock-out-1RCC_MCO_1 (DCMI_XCLX)PA8
SYSSerial WireSYS_JTCK-SWCLKPA14
SYSSerial WireSYS_JTMS-SWDIOPA13
SYSSysTickSYS_VS_SystickVP_SYS_VS_Systick
USART3AsynchronousUSART3_RXPD9
USART3AsynchronousUSART3_TXPD8
GPIOOutputCAMERA_RESETPG0
GPIOOutputCAMERA_PWDNPG1
GPIOEXTI13USER_BtnPC13

DCMI configuration:

OPTIONVALUE
Pixel clock polarityActive on Rising edge
Vertical synchronization polarityActive Low
Horizontal synchronization polarityActive Low
Frequency of frame captureAll frames are captured
JPEG modeEnabled

I2C configuration:

I2C Speed ModeStandard Mode
I2C Speed Frequency (KHz)100
Rise Time (ns)0
Fall Time (ns)0
Coefficient of Digital Filter0
Analog Filter0
Timing0x1060669A
Clock No Stretch ModeDisabled
General Call Address DetectionDisabled
Primary Address Length selection7-bit
Primary slave address0

USART configuration:

OPTIONVALUE
Baud Rate115200
Word Length8 Bits(including Parity)
ParityNone
Stop Bits1
Coefficient of Digital Filter0
Data DirectionReceive and Transmit
Over Sampling16 Samples
Single SampleDisable
Auto BaudrateDisable
TX Pin Active Level InversionDisable
RX Pin Active Level InversionDisable
Data InversionDisable
TX and RX PinsSwapping
OverrunEnable
DMA on RX ErrorEnable
MSB FirstDisable

DMA configuration:

DMA requestStreamDirectionPriority
DCMIDMA2_Stream1PeripheralTo MemoryVery High
USART3_TXDMA1_Stream3Memory To PeripheralVery High

DMA2_Stream1 DMA request settings:

OPTIONVALUE
ModeCircular
Use fifoEnable
FIFO ThresholdFull
Peripheral IncrementDisable
Memory IncrementEnable
Peripheral Data WidthWord
Memory Data WidthByte
Peripheral Burst SizeSingle
Memory Burst SizeSingle

DMA1_Stream3 DMA request settings

OPTIONVALUE
ModeNormal
Use fifoEnable
FIFO ThresholdFull
Peripheral IncrementDisable
Memory IncrementEnable
Peripheral Data WidthByte
Memory Data WidthByte
Peripheral Burst SizeSingle
Memory Burst SizeSingle

NVIC configuration

Interrupt TableEnablePreenmption PrioritySubPriority
Non maskable interrupttrue00
Hard fault interrupttrue00
Memory management faulttrue00
Pre-fetch fault, memory access faulttrue00
Undefined instruction or illegal statetrue00
System service call via SWI instructiontrue00
Debug monitortrue00
Pendable request for system servicetrue00
System tick timertrue00
DMA1 stream3 global interrupttrue00
USART3 global interrupttrue00
DMA2 stream1 global interrupttrue00
DCMI global interrupttrue00
PVD interrupt through EXTI line 16unused
Flash global interruptunused
RCC global interruptunused
I2C1 event interruptunused
I2C1 error interruptunused
EXTI line[15:10]interruptsunused
FPU global interruptunused

📚 Example use

1. Receive the data using a terminal or other software, default speed is set to 115200 baud.

2. Save the data dump to a file.

3. Open the file and search for the beginning of the JPEG header, it must be FFF8 value.

Open file and serach header

4. In the opened file search for the end of the data, this must be FFD9 value.

Serach footer of jpeg file

5. Open the hexadecimal editor. The example uses https://hexed.it/ and copy the data from the data dump.

Copy data from data dump to hexadecimal editor

6. Our data must start with FFD8 and end with FFD9.

JPEG header JPEG footer

7. Save and open the newly created file.

enter image description here

8. Now it's all depending on you.

Example image #1 Example image #2 Example image #3

💀 My code doesn't work, nothing happens, what to do?

You need to make sure that:

  1. Using short connection wires , less than 10 cm (3.93 inches) - This is very, very, very important!,
  2. All wires are properly connected,
  3. Have a high enough clock speed for the MCU,

Use 320x240px resolution for testing - it always works :-)

Similar Projects

Discover other similar projects and AI models.

RepositoryC
Genymobile/scrcpy

Display and control your Android device

156.4k
Dec 1, 2026
RepositoryC
MaJerle/stm32-usart-uart-dma-rx-tx

STM32 examples for USART using DMA for efficient RX and TX transmission

1.8k
Sep 12, 2026
RepositoryC
nimaltd/ws28xx

ws28xx (ws2811, ws2812, ws2812b, ws2815, ...) Library for STM32 (PWM+DMA)

108
Oct 2, 2026
RepositoryC++
modm-io/modm

modm: a C++23 library generator for AVR and ARM Cortex-M devices

1.0k
Nov 27, 2026
Repository
STMicroelectronics/stm32ai-modelzoo

AI Model Zoo for STM32 devices

802
Nov 30, 2026
RepositoryC
obsproject/obs-studio

OBS Studio - Free and open source software for live streaming and screen recording

80.4k
Nov 29, 2026
RepositoryC
FFmpeg/FFmpeg

Mirror of https://git.ffmpeg.org/ffmpeg.git

68.4k
Nov 29, 2026
RepositoryC
git/git

Git Source Code Mirror - This is a publish-only repository but pull requests can be turned into patches to the mailing list via GitGitGadget (https://gitgitgadget.github.io/). Please follow Documentation/SubmittingPatches procedure for any of your improvements.

64.6k
Nov 30, 2026
RepositoryC
curl/curl

A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, MQTTS, POP3, POP3S, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET, TFTP, WS and WSS. libcurl offers a myriad of powerful features

43.7k
Nov 28, 2026