Ov7670 Camera Module Connection With STONE HMI DISPLAY

Introduction: Ov7670 Camera Module Connection With STONE HMI DISPLAY

This article will introduce ov7670 camera module connection with STONE LCD.

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 STONE LCD, main function:

1. The display screen displays the pictures collected by the camera in real time

2. Click the button to shoot an image and save it to the TF card

3. Switch colors and grayscale

4. Resolution can be switched (240*320, 240*240, 160*160, 80*80)

5. You can switch to the mode of viewing pictures

6. You can browse the last picture

7. You can browse to the next picture

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

1. STONE 7-inch 800*480 resolution serial display module

2. STM32F103ZE development board

3. OV7670 camera module

4. A small amount of relevant wire We can first look at the pictures of the related hardware modules:

STONE 7 "800*480 resolution serial display module

STM32F103ZE development board

This development board has a number of integrated features:
1. Cotex-m3 core chip, STM32F103ZET6,

2. 144P pin

3. External crystal oscillator 8M, clock crystal oscillator 32768Hz

4. Standard 20P socket, JTAG interface, used for downloading debugging programs such as Jlink, Ulink and st-link

5. Standard 4P pin insertion, SWD interface, use 2-wire communication to debug and download the program

6. All I/O ports are used to insert needles for convenient experiment expansion

7. Usb-ttl serial port conversion circuit, realizing serial port communication of USB interface

8, automatic download adaptor circuit, use serial port download without frequent switching, a key to download MAX232 conversion circuit, suitable for external serial line

10. Integrated infrared receiver, user remote infrared receiving function

11, DS18B20 socket, directly inserted into the chip to achieve digital temperature measurement function

12, with clock backup battery, keep the clock and important information not lost power

13. EEPROM chip 24c02 to store common user information and use IIC for communication

14, FLASH chip W25Q64,8M memory, can store pictures, system data and other information

15. SPI mode SD card holder, TF card, PI communication

16. SDIO mode SD card holder, TF card, dedicated SDIO interface, high speed, stable.

17. RF24L01 socket for testing wireless communication (at least 2 machines are required)

18. 3-way normal key input function, man-machine interface

19, 1 way wake up button, used to wake up from low power consumption or standby mode

20. LED lamp of the 2-way user, making basic state and operation instructions

21, 1 USB device interface, used for debugging USB device functions, such as card reader, USB serial port functions

22. TFT color screen LCD interface, including touch screen interface, can be directly inserted into the supporting screen

23. Camera reserved interface, supporting camera module to achieve video presentation function

24. No. 1 buzzer

25, 1 touch button function

26. Self-recovery fuse to protect the computer from damage

27. Reset button

28. Power indicator

Choose to insert the pin

30. Select the pin with VREF reference voltage

31, CAN, USB switch pin

32. 3.3v outboard power supply pin insertion

33. 5V external expansion power supply pin insertion

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

Step 1: 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 instruction to the STONE, the contents of the display module, control is ok, the same principle, when a user touch 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:

1、 Main packing list:
2、 1. Transfer connection and connection

3、 2. Usb-ttl adapter board

4、 3. Usb flash drive (including development materials)

5、 4. Micro USB cable

6、 5. USB transfer board

7、 6. STONE stvc070wt-01 display module

12V power adapter

STONE Display module profile
Stvc070wt-01 is a TFT display and touch controller.It includes 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

Step 2: STVC070WT-01 Display Module Control Principle

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

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

Using STONE's tft-lcd module requires only 3 steps:
1. Design a set of man-machine pictures (UI).

2. Uart-ttl directly connects to the customer's MCU.

3. Write a simple program, by the MCU through 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.

Step 3: Application Scenarios of STONE TFT-LCD Display Module

The STONE display module is widely used in a variety of industrial applications, such as:

1. Medical beauty equipment

2. Engineering machinery and vehicle equipment

3. Electronic instruments

4. Industrial control system

5. Power industry

6. Civil electronic equipment

7. Automation equipment

8. Traffic.

Step 4: UI Picture Design

The user designs the UI using Photoshop or other software

The interface I designed is as follows:

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

Step 5: Use the TOOL2019 Software Set to Generate the LCD Module Configuration File

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.

Step 6: 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 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.

Step 7: Accessories Used in the Project

Main accessories are:

1. STM32F103ZE development board

2. Dc-dc step-down module

3. 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:

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

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

Step 8: OV7670 Camera Module

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 SCCB interface.OmmiVision 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:

1. High sensitivity, low voltage suitable for embedded applications

2. Standard SCCB interface, compatible with IIC interface

3. Support RawRGB, RGB(gbr4:2:2, RGB565/RGB555/RGB444), YUV(4:2:2) and YCbCr

4. Supports VGA, CIF, and all sizes from CIF to 40*30

5. Support automatic exposure control, automatic gain control, automatic white balance and automatic elimination of light streaks

6. Automatic black level calibration and other automatic control functions.At the same time support color saturation, hue, gamma, sharpness and other Settings.

7. Flash support 8. Supports image scaling Functional block diagram of OV7670:

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 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:

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) :

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.

Step 9: The Driver Code for OV7670

u8 OV7670_Init(void)

{ u8 temp; u16 i=0; GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOG, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_SetBits(GPIOB,GPIO_Pin_3|GPIO_Pin_4); GPIO_InitStructure.GPIO_Pin = 0xff; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_SetBits(GPIOD,GPIO_Pin_6); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14|GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOG, &GPIO_InitStructure); GPIO_SetBits(GPIOG,GPIO_Pin_14|GPIO_Pin_15); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); //SWD SCCB_Init(); //³õʼ»¯SCCB µÄIO¿Ú if(SCCB_WR_Reg(0x12,0x80))return 1; //¸´Î»SCCB delay_ms(50); temp=SCCB_RD_Reg(0x0b); if(temp!=0x73)return 2; temp=SCCB_RD_Reg(0x0a); if(temp!=0x76)return 2; //³õʼ»¯ÐòÁÐ for(i=0;i>3); SCCB_WR_Reg(0X18,endx>>3); //ÉèÖÃVREF temp=SCCB_RD_Reg(0X03); temp&=0XF0; temp|=((endy&0X03)<<2)|(sy&0X03); SCCB_WR_Reg(0X03,temp); SCCB_WR_Reg(0X19,sy>>2); SCCB_WR_Reg(0X1A,endy>>2);

Step 10: 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.

Step 11: STM32F103ZE

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

This is the development board for STM32F103ZE:

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

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.

Step 12: 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:

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

Step 13: 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 subdistributed.

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: TAKE PICTRUE BUTTON : 0X002A COLOR&GRAY BUTTON : 0X002B CHANGE RATION BUTTON:0X002C PREV PICTURE BUTTON:0X002D NEXT PICTURE BUTTON:0X002E BROWSE BUTTON : 0X002F The Main function code is as follows: #include "led.h" #include "delay.h" #include "key.h" #include "sys.h" #include "lcd.h" #include "usart.h" #include "string.h" #include "ov7670.h" #include "tpad.h" #include "timer.h" #include "exti.h" #include "usmart.h" #include "dma.h" #include "sdio_sdcard.h" extern u8 ov_sta; extern u8 img_dis_cnt; extern u8 data_ready; extern u8 USART_RX_END; u16 user_width=240; u16 user_heigh=240; #define PIC_TOTAL 20 u8 sd_select=1; u16 color_r; u16 color_g; u16 color_b; void UART1_Send_Array(u8 send_array[],u16 num) { u16 i=0; while(iCFGR&=0XFFFFFFFC; RCC->CR&=~0x01000000; RCC->CFGR&=~(0XF<<18); PLL-=2;//µÖÏû2¸öµ¥Î» RCC->CFGR|=PLL<<18; RCC->CFGR|=1<<16; //PLLSRC ON FLASH->ACR|=0x12; RCC->CR|=0x01000000; //PLLON while(!(RCC->CR>>25)); RCC->CFGR|=0x02; while(temp!=0x02) { temp=RCC->CFGR>>2; temp&=0x03; } } #define SEND_BUF_SIZE 169 #define LCD_X_H 5 #define LCD_X_L 6 #define LCD_Y_H 7 #define LCD_Y_L 8 u8 lcd_send_buf[SEND_BUF_SIZE]={0xa5,0x5a,0xa6,0x85,0x00,0x00,0x00,0x00,0x00}; u8 lcd_send_buf1[512]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; u8 upda_flag=1; u16 dis_fixel=0; void camera_refresh() { u16 i=0,j=0,k=0; u8 color; u8 cnt=9; u16 user_x_cnt=0,user_x_start=0,lcd_send_times=0; u16 user_width1=user_width; u16 user_heigh1=user_heigh; if(user_width1==240) { user_x_cnt=2; user_x_start=450; } else if(user_width1==320) { user_x_cnt=3; user_x_start=410; } else if(user_width1==160) { user_x_cnt=1; user_x_start=490; } else if(user_width1==80) { user_x_cnt=0; user_x_start=530; } if(ov_sta==2) { OV7670_RRST=0; OV7670_RCK_L; OV7670_RCK_H; OV7670_RCK_L; OV7670_RRST=1; OV7670_RCK_H; upda_flag=0; for(i=0;i> 8); cnt=9; lcd_send_times=0; for(j=0;jIDR&0XFF; OV7670_RCK_H; lcd_send_buf[cnt++]=color; if(cnt > 168) { if(lcd_send_times==0) { dis_fixel=user_x_start; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); } else if(lcd_send_times==1) { dis_fixel+=80; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); } else if(lcd_send_times==2) { dis_fixel+=80; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); } else if(lcd_send_times==3) { dis_fixel+=80; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); } if(USART_RX_END==1) { EXTI_ClearITPendingBit(EXTI_Line8); ov_sta=0; upda_flag=1; return; } else { UART1_Send_Array(lcd_send_buf,169); } lcd_send_times++; if(lcd_send_times>user_x_cnt) lcd_send_times=0; cnt=9; } } } EXTI_ClearITPendingBit(EXTI_Line8); ov_sta=0; upda_flag=1; } } void clear_display() { u16 i=0,j=0,k=0; u8 cnt=9,lcd_send_times=0; u8 color; u16 user_x_cnt=0,user_x_start=0; u16 user_width1=user_width; u16 user_heigh1=user_heigh; if(user_width1==240) { user_x_cnt=2; user_x_start=450; } else if(user_width1==320) { user_x_cnt=3; user_x_start=410; } else if(user_width1==160) { user_x_cnt=1; user_x_start=490; } else if(user_width1==80) { user_x_cnt=0; user_x_start=530; } upda_flag=0; for(i=0;i> 8); cnt=9; lcd_send_times=0; for(j=0;jIDR&0XFF; OV7670_RCK_H; lcd_send_buf[cnt++]=0xff; if(cnt > 168) { if(lcd_send_times==0) { dis_fixel=user_x_start; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); } else if(lcd_send_times==1) { dis_fixel+=80; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); } else if(lcd_send_times==2) { dis_fixel+=80; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); } else if(lcd_send_times==3) { dis_fixel+=80; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); } UART1_Send_Array(lcd_send_buf,169); lcd_send_times++; if(lcd_send_times>user_x_cnt) lcd_send_times=0; cnt=9; } } } EXTI_ClearITPendingBit(EXTI_Line8); ov_sta=0; upda_flag=1; } void user_save_image() { u16 i=0,j=0,k=0; u8 color; u8 cnt=9,m_cnt=0; u16 user_x_cnt=0,user_x_start=0,lcd_send_times=0; u16 user_width1=user_width; if(user_width1==240) { user_x_cnt=2; user_x_start=450; } else { return; } while(ov_sta!=2); if(ov_sta==2) { OV7670_RRST=0; OV7670_RCK_L; OV7670_RCK_H; OV7670_RCK_L; OV7670_RRST=1; OV7670_RCK_H; upda_flag=0; for(i=0;i<240;i++) { k=i+150; lcd_send_buf[LCD_Y_L] = (u8)(k & 0x00ff); lcd_send_buf[LCD_Y_H] = (u8)(k >> 8); cnt=9; lcd_send_times=0; for(j=0;j<240*2;j++) { OV7670_RCK_L; color=(u8)GPIOC->IDR&0XFF; OV7670_RCK_H; lcd_send_buf[cnt++]=color; if(cnt > 168) { m_cnt=0; if(lcd_send_times==0) { dis_fixel=user_x_start; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); for(m_cnt=0;m_cnt<169;m_cnt++) { lcd_send_buf1[m_cnt]=lcd_send_buf[m_cnt]; } } else if(lcd_send_times==1) { dis_fixel+=80; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); for(m_cnt=0;m_cnt<169;m_cnt++) { lcd_send_buf1[m_cnt+169]=lcd_send_buf[m_cnt]; } } else if(lcd_send_times==2) { dis_fixel+=80; lcd_send_buf[LCD_X_H] =(u8)(dis_fixel >> 8); lcd_send_buf[LCD_X_L] = (u8)(dis_fixel & 0x00ff); for(m_cnt=0;m_cnt<169;m_cnt++) { lcd_send_buf1[m_cnt+169*2]=lcd_send_buf[m_cnt]; } } UART1_Send_Array(lcd_send_buf,169); lcd_send_times++; if(lcd_send_times>user_x_cnt) { SD_WriteDisk(lcd_send_buf1,i+240*sd_select,1); lcd_send_times=0; } cnt=9; } } } } EXTI_ClearITPendingBit(EXTI_Line8); ov_sta=0; upda_flag=1; } void read_image() { u8 i=0; for(i=0;i<240;i++) { if(SD_ReadDisk(lcd_send_buf1,i+240*sd_select,1)==0) { UART1_Send_Array(lcd_send_buf1,507); } } } int main(void) { u8 pixel_ch_flag=0,user_effect_flag=0; delay_init(); NVIC_Configuration(); uart_init(921600); LED_Init(); LCD_Init(); delay_ms(1000); delay_ms(1000); while(OV7670_Init())//³õʼ»¯OV7670 { delay_ms(200); } while(SD_Init()) { delay_ms(500); LED0=!LED0; } if(SD_ReadDisk(lcd_send_buf1,240*(PIC_TOTAL+10),1)==0) { sd_select=lcd_send_buf1[0]; if(sd_select>=PIC_TOTAL ) { lcd_send_buf1[0]=0x00; SD_WriteDisk(lcd_send_buf1,240*(PIC_TOTAL+10),1); sd_select=0; } } //show_sdcard_info(); EXTI8_Init(); OV7670_CS=0; config_ov7670_OutPut(20,60,user_width,user_heigh,0); while(1) { if(USART_RX_END==1) { switch(USART_RX_BUF[5]) { case 0x2c: clear_display(); pixel_ch_flag+=1;//!pixel_ch_flag; if(pixel_ch_flag>3) pixel_ch_flag=0; if(pixel_ch_flag==1) { user_width=160; user_heigh=160; } else if(pixel_ch_flag==2) { user_width=80; user_heigh=80; } else if(pixel_ch_flag==3) { user_width=320; user_heigh=240; } else { user_width=240; user_heigh=240; } config_ov7670_OutPut(20,60,user_width,user_heigh,0); if(user_effect_flag) OV7670_Special_Effects(1); else OV7670_Special_Effects(0); break; case 0x2b: user_effect_flag=!user_effect_flag; if(user_effect_flag) OV7670_Special_Effects(1); else OV7670_Special_Effects(0); break; case 0x2a: if(user_width!=240)break; if(img_dis_cnt==0) { img_dis_cnt=1; } else { if(SD_ReadDisk(lcd_send_buf1,240*(PIC_TOTAL+10),1)==0) { if(lcd_send_buf1[0]>=PIC_TOTAL) { lcd_send_buf1[0]=PIC_TOTAL; sd_select=1; } else { sd_select=lcd_send_buf1[0]+1; lcd_send_buf1[0]=sd_select; } SD_WriteDisk(lcd_send_buf1,240*(PIC_TOTAL+10),1); user_save_image(); //sd_select=lcd_send_buf1[0]; } } break; case 0x2d: if(SD_ReadDisk(lcd_send_buf1,240*(PIC_TOTAL+10),1)==0) { if(lcd_send_buf1[0]==0) break; else { sd_select-=1; if(sd_select==0)sd_select=lcd_send_buf1[0]; } if(sd_select>lcd_send_buf1[0]) sd_select=1; } if(user_width==320) clear_display(); read_image(); img_dis_cnt=0; break; case 0x2e: if(SD_ReadDisk(lcd_send_buf1,240*(PIC_TOTAL+10),1)==0) { if(lcd_send_buf1[0]==0) break; if(sd_select>=lcd_send_buf1[0]) { sd_select=1; } else { sd_select+=1; } } if(user_width==320) clear_display(); read_image(); img_dis_cnt=0; break; case 0x2f: img_dis_cnt=0; break; default: break; } USART_RX_END=0; USART_RX_STA=0; } else { // USART_RX_END=0; // USART_RX_STA=0; if(img_dis_cnt==1) camera_refresh(); } } } 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.

Step 14: Running Effect

Questions related to project development. Please go to the stone official forum for technical questions.

https://forum.stoneitech.com/

Be the First to Share

    Recommendations

    • Home Decor Challenge

      Home Decor Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Barbecue Speed Challenge

      Barbecue Speed Challenge

    Comments