Getting to know OV5640

Ref: OV5640

What is OV5640?

OV5640 is a CMOS type digital image sensor. The sensor supports the output of images with a maximum of 5 million pixels (2592×1944 resolution), supports the use of VGA timing output image data, the output image data format supports YUV (422/420), YCbCr422, RGB565 and JPEG format, if directly output JPEG format The image can greatly reduce the amount of data and facilitate network transmission. It can also compensate the captured images and support basic processing such as gamma curve, white balance, saturation, and chroma.

OV5640 pin and functional block diagram

The OV5640 module has an auto focus function. The pin definition is as follows:

  • SIO_C: The clock line of the SCCB bus, similar to the SLC of I2C.
  • SIO_D: Data line of SCCB bus, similar to SDA of I2C.
  • RESET: System reset, active low.
  • PWDN: Power-down/power-saving mode, active at high level.
  • HREF: horizontal synchronization signal.
  • VSYNC: Frame synchronization signal.
  • PLCK: Pixel synchronization clock output signal.
  • XLCK: External clock access port, external crystal oscillator can be used.
  • Y2~Y9: Pixel data output port.

Functional block diagram of OV5640

The functional block diagram of OV5640 reflects its working principle.

Control register

The label is the control register of OV5640, which runs according to the parameters configured by these registers, and these parameters are written by the external controller through the SIO_C and SIO_D pins. The communication protocol used by SIO_C and SIO_D is very similar to I2C.

Communication, control signal and clock

The label ‚contains the communication, control signals and external clock of the OV5640, among which PCLK, HREF and VSYNC are the pixel synchronization clock, the line synchronization signal and the frame synchronization signal respectively, which are very similar to the signals in the LCD control. When the RESETB pin is low, it is used to reset the entire sensor chip, and PWDN is used to control the chip to enter a low power consumption mode. XCLK is the clock signal used to drive the entire sensor chip and is the signal input to the OV5640 from outside; while PCLK is the synchronization signal when the OV5640 outputs data. OV5640 output signal. The relationship between XCLK and OV5640 is similar to the relationship between the HSE clock input pin and the STM32 chip.

Photosensitive matrix

The label ƒ is the photosensitive matrix, where light signals are converted into electrical signals, and after various processes, these signals are stored into digital images represented by individual pixels.

Data output signal

The DSP processing unit performs some basic image processing operations according to the configuration of the control register. This part also contains image format conversion unit and compression unit, and the converted data is finally output through Y0-Y9 pins. At this time, only the Y2-Y9 pins are used. The connection between OV5640 and external devices is shown in the figure below.

Data output signal

VCM processing unit, it will realize the automatic focus function of the image through image analysis. To achieve auto focus, you need to download auto focus firmware to the module.

SCCB timing

The configuration parameters of the external controller to the OV5640 register are transmitted through the SCCB bus, and the SCCB bus is very similar to I2C, so we directly use the on-chip I2C peripheral to communicate with it in the STM32 driver. There is a difference between SCCB and the standard I2C protocol. SCCB can only write or read one byte of data per transmission, while the I2C protocol supports reading and writing, that is, multiple bytes can be written in one transmission data (the timing of page writing in EEPROM is Burst write).

SCCB start, stop signal and data validity.

Start signal: When SIO_C is high, there is a falling edge on SIO_D, then SCCB starts to transmit.

Stop signal: When SIO_C is high, there is a rising edge on SIO_D, then SCCB stops transmitting.

Data validity: In addition to the start and stop states, when data is being transmitted and SIO_C is high, the data on SIO_D must be stable, that is, only when SIO_C is low, the level on SIO_D will occur Variety. Collect when SIO_C is high.

SCCB stop signal:

SCCB data read and write process

The read and write operations defined in the SCCB protocol are also the same as I2C, but in a different way. It defines two write operations, namely three-step write operation and two-step write operation. The three-step write operation can write data to a destination register of the slave device. In the three-step write operation, the first stage sends the ID address of the slave device + W flag (equal to the I2C device address: 7-bit device address + read and write direction flag), and the second stage sends the 16-bit address of the target register of the slave device. The third stage sends 8-bit data to be written into the register. The “X” data bit in the figure can be written with 1 or 0, which has no effect on communication.

The two-step write operation does not have the third stage, that is, only the device ID+W flag and the address of the destination register are transmitted to the slave device. The two-step write operation is used to coordinate the subsequent read register data operation. It is used together with the read operation to realize the I2C compound process.

The register of OV5640

Controlling OV5640 involves many of its registers. Through the configuration of these registers, you can control the resolution, image format and image direction of its output image. It should be noted that the OV5640 register address is 16 bits.

OV5640 can be applied in fields such as smart car drones. In the progress of the project, PCB assembly is particularly important. And Seeed Fusion is a professional PCBA manufacturer.


September 2020