Docs

Micro-controllers, wireless transmission and database

Head

OV7670 Camera with STM32F407VET6 using STM32CubeIDE

STM32CubeIDE Settings

Click RCC → High Speed Clock (HSE) to Crystal/Ceramic Resonator

(Tick) Master Clock Output 1

Configuration → GPIO Settings → Select PA8 Maximum Output Speed to Very High

Click Clock Configuration tab → HSE Input Frequency 8

Select HSE & Select PLLCLK → HCLK (MHz) to 168

MCO1 Source MUX → Select PLLCLK → and /4 to get speed 42MHz

Click Pinout and Configuration tab


Click connectivity → Click I2C2

For I2C select I2C

Configuration → GPIO Settings → Select PB10 and PB11 → GPIO pullup


Click connectivity → Click FSMC

Expand NOR Flash and Tick NE1 Chip select

Memory Type → LCD Interface → LCD Register select A18 → Data 16 bits

NOR/PSRAM Timing → Address setup - 1 & Data setup - 5 & Bus turn around - 0


Click Multimedia → Click DCMI

DCMI → Slave 8 bits external Synchro

Configuration → Parameter Settings

Pixel clock polarity → Active on rising edge

Vertical syncronisation polarity → Active High

Configuration → GPIO Settings → Select All pins

GPIO Pull down & Maximum output speed to Very High

Configuration → DMA Settings → Click add button → Select DCMI →

Configuration → NVIC Settings → DCMI global interrupt (Tick)

Move DCMI_D4 from PE4 to PC11

Move DCMI_D6 from PE5 to PB8

Move DCMI_D7 from PE6 to PB9


Set PD11, PD12 and PB1 to GPIO_Output

Set PD11 User lable to CAMERA_RESET

Libraries

Taken from https://github.com/iwatake2222/DigitalCamera_STM32

Inside Core/Inc Folder

common.h

lcdIli9341.h

lcdIli9341Config.h

#define FSMC_Ax 16 // use A16 as RS *** CHANGE LINE NO 12 to ***
#define FSMC_Ax 18 // use A18 as RS

ov7670.h

ov7670Config.h

ov7670Reg.h

Inside Core/Src Folder

lcdIli9341.c

ov7670.c

Additional code on top of STM32CubeIDE generated code

/* USER CODE BEGIN Includes */
#include "common.h"
#include "lcdIli9341.h"
#include "ov7670.h"
#include "lcdIli9341Config.h"
/* USER CODE END Includes */
  /* USER CODE BEGIN 2 */
  uint16_t* pData;
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_RESET); //Camera PWDN to GND
  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET); //LCD Backlight to 3V3
  lcdIli9341_init();
  lcdIli9341_drawRect(0, 0, 320, 240, LCD_ILI9342_COLOR_RED);
  ov7670_init(&hdcmi, &hdma_dcmi, &hi2c2);
  ov7670_config(OV7670_MODE_QVGA_RGB565);
  pData = lcdIli9341_getDrawAddress();
  ov7670_startCap(OV7670_CAP_CONTINUOUS, pData);
  /* USER CODE END 2 */