by hearingearly hearingearly

  This article will introduce the ov7670 camera module connection with the STONE display module. displaying camera images through a serial display module. The methods and code described in this article are for individual developer testing only and cannot guarantee commercial stability.

  ov7670 camera module connection with the STONE display module, the main function

  The display screen displays the pictures collected by the camera in real-time
Click the button to shoot an image and save it to the TF card
Switch colors and grayscale
Resolution can be switched (240*320, 240*240, 160*160, 80*80)
You can switch to the mode of viewing pictures
You can browse the last picture
You can browse to the next picture

  Before proceeding with this project, let’s take a look at what hardware modules are needed.

STONE 7-inch 800*480 resolution serial display module
STM32F103ZE development board
OV7670 camera module
A small amount of relevant wire

  STM32F103ZE development board

  ov7670-camera-module-connection-with STONE-display-module

  This development board has a number of integrated features

  Cortex-m3 core chip, STM32F103ZET6,
144P pin
External crystal oscillator 8M, clock crystal oscillator 32768Hz
Standard 20P socket, JTAG interface, used for downloading debugging programs such as Jlink, Ulink and st-link
Standard 4P pin insertion, SWD interface, use 2-wire communication to debug and download the program
All I/O ports are used to insert needles for convenient experiment expansion
USB-TTL serial port conversion circuit, realizing serial port communication of USB interface
automatic download adaptor circuit, use serial port download without frequent switching, a key to download
MAX232 conversion circuit, suitable for external serial line
Integrated infrared receiver, user remote infrared receiving function
DS18B20 socket, directly inserted into the chip to achieve digital temperature measurement function
with clock backup battery, keep the clock and important information not lost power
EEPROM chip 24c02 to store common user information and use IIC for communication
FLASH chip W25Q64,8M memory, can store pictures, system data, and other information
SPI mode SD card holder, TF card, PI communication
SDIO mode SD card holder, TF card, dedicated SDIO interface, high speed, stable.
RF24L01 socket for testing wireless communication (at least 2 machines are required)
3-way normal key input function, man-machine interface
1 way wake up button, used to wake up from low power consumption or standby mode
LED lamp of the 2-way user, making basic state and operation instructions
1 USB device interface, used for debugging USB device functions, such as card reader, USB serial port functions
TFT color screen LCD interface, including touch screen interface, can be directly inserted into the supporting screen
Camera reserved interface, supporting camera module to achieve video presentation function
No. 1 buzzer
1 touch button function
self-recovery fuse to protect the computer from damage
Reset button
Power indicator
Choose to insert the pin
Select the pin with VREF reference voltage
CAN, USB switch pin
3.3v outboard power supply pin insertion
5V external expansion power supply pin insertion

  But in fact, we only use his camera interface and serial port, and TF card interface

  STONE TFT-LCD Display module

  STONE STVC070WT-01 is a 7-inch display module with a resolution of 800*480. This display module can be purchased from STONE’s official website or from STONE’s online shopping platform link.

  The communication mode of STONE stvc070wt-01 is uart-rs232 and uart-ttl.In this project, I used uart-TTL communication mode.

  Display module development way is simple, the MCU only need through UART send an instruction to the STONE, the contents of the display module, control is ok, the same principle when a user touches the STONE display screen, display module and related instructions sent to MCU through UART, and then MCU to control the corresponding devices (such as motor rotation, light switch, etc.).

  7 inches STONE STVC070WT-01

  The materials provided by the manufacturer are as follows:

  ov7670-camera-module-connection-with STONE-display-module

  Main packing list

  Transfer connection and connection
USB-TTL adapter board
USB flash drive (including development materials)
Micro USB cable
USB transfer board
STONE STVC070WT-01 display module
12V power adapter

  STONE Display module profile

  STVC070WT-01 is a TFT display and touch controller. It includes a processor, control program, driver, flash, RS232/RS485/TTL port, touch screen, power supply, etc., is a powerful display system

  The operating system is simple and can be controlled by any single-chip microcomputer.STVC070WT-01 can be used to perform all basic functions, such as text display, image display, curve display, touch function, video and audio function, etc.

built-in Cortex CPU and drivers
can be controlled by any single-chip microcomputer
display pictures/text/curves
65536 color TFT display
– can be touched
RS232/ RS485/ TTL UART interface and USB port
wide voltage range

  STVC070WT-01 Display module control principle

  The TFT-LCD module communicates with the MCU by the command (hexadecimal), and the MCU will work according to the command it receives.

  ov7670-camera-module-connection-with STONE-display-module

  Three steps are required to complete the firmware development of the STONE display module

  Using STONE’s TFT-LCD module requires only 3 steps:

Design a set of man-machine pictures (UI).
UART-TTL directly connects to the customer’s MCU.
Write a simple program, by the MCU through the command control TFT-LCD module. (hexadecimal code).

  The serial command frame of the TFT LCD module consists of five data blocks, all of which are represented in hexadecimal format. The way data is transferred to MSB.For example, for 0x1234, 0x12 is sent first, and then 0x34 is sent.

  UI picture design

  The user designs the UI using Photoshop or other software

  The interface I designed is as follows:

  ov7670-camera-module-connection-with STONE-display-module

  The first picture is the main screen picture, and the second picture is the effect when the button is pressed.

  Use the TOOL2019 software set to generate the LCD module configuration file

  ov7670-camera-module-connection-with STONE-display-module

  Click the arrow button to generate the configuration file, and then download the configuration file to the display module to display the UI interface we designed.

  I won’t go into the details of this part of the content and tutorial, you can go to the STONE website to download a very detailed tutorial.

  In addition, we also need to design an identical picture as the effect when the button is pressed. We just need to change the color of the button position to the following table.

  ov7670-camera-module-connection-with STONE-display-module

  STM32 MCU and VO7670 Wiring and welding

  In the previous content, I introduced the relevant development operation of STONE STVC070WT-01. In the following content, I will focus on the STM32 MCU and the VO7670 camera. Before we do that, let’s take a look at how the hardware part of the project connects.

  A complete wiring diagram for the STONE project

  ov7670-camera-module-connection-with STONE-display-module

  OV7670 module — STM32 development board:

  OV_D0 ~ D7 — — — — — — — — — — – PC0 ~ 7

  OV_SCL — — — — — — — — — — — — PD3

  OV_SDA — — — — — — — — — — — — PG13

  OV_VSYNC — — — — — — — — — — — — PA8

  FIFO_RRST — — — — — — — — — — – PG14

  FIFO_OE — — — — — — — — — — – PG15

  FIFO_WRST — — — — — — — — — — — — PD6

  FIFO_WEN — — — — — — — — — — — — PB3

  FIFO_RCLK — — — — — — — — — — — — PB4

  The power adapter is 12V and needs to power the STONE stvc070wt-01 display module and power the MCU module and OV7670 through the dc-dc step-down to 5 volts.

  Accessories used in the project

  The main accessories are:

STM32F103ZE development board
Dc-dc step-down module
UART switching

  Since the default communication mode of STONE STVC070WT-01 is uart-TTL, we do not need the interface of RS232 for switching connection, and remove the interface of RS232:

  ov7670-camera-module-connection-with STONE-display-module


  By welding these parts together, the effect is as follows:

  ov7670-camera-module-connection-with STONE-display-module

  ov7670-camera-module-connection-with STONE-display-module

  When this part is ready, you can write the program for the MCU.

  OV7670 camera module

  Functional block diagram of OV7670

  OV7670 is a kind of image sensor, the operating temperature is -30℃-70℃, the analog voltage is 2.5-3.0v, the photosensitive array is 640*480, and the power consumption is 60mW/15fps.Less than 20uA in dormancy.

  Small size, low operating voltage, providing all the features of a single VGA camera and image processor. Through SCCB bus control, you can input the whole frame, sub-sampling, window, and other ways of various resolution 8-bit image data. The product’s VGA image reaches a maximum of 30 frames per second. Users have complete control over image quality, data format, and transmission. All image processing functions including gamma curve, white balance, saturation, chroma, etc. can be programmed through the SCCB interface. By reducing or eliminating optical or electronic defects such as fixed pattern noise, tail support, floating, and so on, image quality can be improved to obtain clear and stable color images.

  OV7670 is a 1/6-inch CMOS VGA image sensor produced by OV (OmniVision).The sensing

  The device is small in size, low in working voltage, and provides all the functions of a single VGA camera and image processor. Through SCCB bus control, you can output the whole frame, sub-sampling, window, and other ways of various resolution 8-bit image data. The product’s VGA image reaches a maximum of 30 frames per second. Users have complete control over image quality, data format, and transmission. All image processing processes including gamma curve, white balance, degree, color, etc. can be programmed through the SCCB interface.OmniVision image sensor USES unique sensor technology to improve the image quality by reducing or eliminating optical or electronic defects such as fixed pattern noise, tail support, floating, etc., to obtain clear and stable color images.

  Features of OV7670 include:

 High sensitivity, low voltage suitable for embedded applications
Standard SCCB interface, compatible with IIC interface
Support RawRGB, RGB(gbr4:2:2, RGB565/RGB555/RGB444), YUV(4:2:2) and YCbCr
Supports VGA, CIF, and all sizes from CIF to 40*30
Support automatic exposure control, automatic gain control, automatic white balance and automatic elimination of light streaks
Automatic black level calibration and other automatic control functions. At the same time support color saturation, hue, gamma, sharpness, and other Settings.
Flash support
Supports image scaling

  The OV7670 sensor includes the following functional modules.

  1. Image Array

  OV7670 has a total of 656*488 pixels, of which 640*480 are valid (i.e., effective pixels are 30W).

  2. Video Timing Generator

  The sequence generator has the following functions: whole sequence control and frame rate generation (output in 7 different formats), internal signal generator 535 and distribution, frame rate timing, automatic exposure control, and output of external timing (VSYNC, HREF/HSYNC, and PCLK).

  3. Analog signal Processing

  Analog signal processing all analog functions and includes automatic gain (AGC) and automatic white balance (AWB).

  4. A/D conversion (A/D)

  After the original signal passes through the analog processor module, it enters A 10-bit A/D converter via G and BR channels.

  The A/D converter operates at an A frequency of 12M, fully synchronized with the pixel frequency (the conversion frequency is related to the frame rate).

  The A/D range product and A/D range control jointly set the A/D range and maximum, allowing the user to adjust the brightness of the image based on the application.

  Next, let’s introduce the image data output format of OV7670. First, let’s briefly introduce some definitions:

  VGA, that is, the output mode with a resolution of 640*480;

  QVGA, the output format with a resolution of 320*240, is the format we need in this chapter.

  QQVGA, that is, the output format with a resolution of 160*120;

  PCLK, or pixel clock, a PCLK clock, outputs one pixel (or half a pixel).

  VSYNC, the frame synchronization signal.HREF /HSYNC, the line synchronization signal.

  OV7670’s image data output (via D[7:0]) is controlled in PCLK, VSYNC, and HREF/ HSYNC

  Below. First, take a look at the timing of the row output, as shown in the figure:

  ov7670-camera-module-connection-with STONE-display-module

  As can be seen from the figure above, the image data is output when the HREF is high, and when the HREF is high when each PCLK

  Clock, output a byte of data. For example, we use VGA timing, RGB565 format output, every 2 bytes constitute a pixel color (high bytes before, low bytes after) so that the output of each line has a total of 640*2 PCLK cycles, the output of 640*2 bytes.

  Frame timing (VGA mode) :

  ov7670-camera-module-connection-with STONE-display-moduleov7670-camera-module-connection-with STONE-display-module

  The figure above clearly shows the data output of OV7670 in VGA mode. Note the HSYNC and HREF in the figure

  It’s actually a signal from the same pin, but in different ways under different situations, we’re using HREF in this chapter.

  Since the pixel clock (PCLK) of OV7670 can reach up to 24Mhz, we use the IO port of STM32F103ZET6 to directly grasp, which is very difficult and takes up a lot of CPU (IO port can be captured by reducing the output frequency of PCLK, but it is not recommended).

  In this project, I used RGB565 mode, and the image data captured was the original data of RGB, which was then transferred to the STONE display module through UART.

  ov7670-camera-module-connection-with STONE-display-module

  The driver code for the OV7670 camera module

  TF card driver

  The project also requires a TF card to store the images taken. Because the TF card driver is too long, I will not post it here. You can search the relevant code on the network to use.


  There are a lot of information and development documents about this chip on the network, here is a brief introduction to this chip.

  ov7670-camera-module-connection-with STONE-display-module

  I won’t say much about this chip. The chip download code USES j-link, as shown in the figure below:

  ov7670-camera-module-connection-with STONE-display-module

  This is a simple version of j-link that only supports SWD debugging and downloading, not JTAG. But for STM32 chip development, SWD debugging is enough.

  Download the code to the STM32 chip

  Make sure the connection between j-link and STM32F103ZE is correct, and then the chip can be identified in the KEIL development environment:

  ov7670-camera-module-connection-with STONE-display-module

  Click the download button to download the code to the chip:

  ov7670-camera-module-connection-with STONE-display-module

  STM32 control code

  The data receiving of the STONE display module can only receive 255 bytes at a time, while the image size of a single RGB565 data is 240*320*2=153600Byte= 153.6kb, so it needs to be sub distributed.

  In addition, due to the limitation of serial communication rate, the effect of picture real-time refresh is not very good. The serial port baud rate is configured to 921600, which is also the highest communication baud rate for the STONE serial display module.

  Buttons and text in the display have corresponding addresses. In this project, the address of the display component is as follows:







  The main function code is as follows:


  Finally, the code is downloaded to the STM32 chip, and then the completed circuit board is connected to the display screen, and the power supply is guaranteed to be stable. You can see the pictures taken by VO7670 through the STONE display module.

  ov7670 camera module connection with STONE display module end of the project.

  Running effect

  ov7670-camera-module-connection-with STONE-display-module

  ov7670-camera-module-connection-with STONE-display-module

OV7670 Camera Module Connection with STONE Display Module