From 5e419eedde69d1e39653bc6fb622739ff384e47a Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Fri, 4 Dec 2020 14:38:19 -0800 Subject: [PATCH 1/2] Fix OV5640 rev Y slock freq scaling --- src/omv/ov5640.c | 8 ++++++++ src/omv/ov5640_regs.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/omv/ov5640.c b/src/omv/ov5640.c index 998c8cc3f..d025a2c74 100644 --- a/src/omv/ov5640.c +++ b/src/omv/ov5640.c @@ -389,6 +389,14 @@ static int reset(sensor_t *sensor) ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, (default_regs[i][0] << 8) | (default_regs[i][1] << 0), default_regs[i][2]); } + #if defined(MCU_SERIES_H7) + // Rev V (480 MHz / 20) -> 24 MHz PCLK / 3 * 100 = 800 MHz / 10 = 80 MHz PCLK. + // Rev Y (400 MHz / 16) -> 25 MHz PCLK / 3 * 84 = 700 MHz / 10 = 70 MHz PCLK. + if (HAL_GetREVID() < 0x2003) { // Is this REV Y? + ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, SC_PLL_CONTRL2, 0x54); + } + #endif + // Delay 300 ms systick_sleep(300); diff --git a/src/omv/ov5640_regs.h b/src/omv/ov5640_regs.h index b4d8885b0..aeffe3679 100644 --- a/src/omv/ov5640_regs.h +++ b/src/omv/ov5640_regs.h @@ -17,7 +17,9 @@ #define SYSTEM_CTROL0 0x3008 +#define SC_PLL_CONTRL1 0x3035 #define SC_PLL_CONTRL2 0x3036 +#define SC_PLL_CONTRL3 0x3037 #define SCCB_SYSTEM_CTRL_1 0x3103 From 7f62250b36ff5d4161a79f8c73f05b8b84b11c0b Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Fri, 4 Dec 2020 15:19:49 -0800 Subject: [PATCH 2/2] Fix OV2640 sensor clock --- src/omv/ov2640.h | 1 + src/omv/ov2640_regs.h | 2 +- src/omv/sensor.c | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/omv/ov2640.h b/src/omv/ov2640.h index 472fe1a14..1c89c569e 100644 --- a/src/omv/ov2640.h +++ b/src/omv/ov2640.h @@ -11,5 +11,6 @@ #ifndef __OV2640_H__ #define __OV2640_H__ #include "sensor.h" +#define OV2640_XCLK_FREQ 24000000 int ov2640_init(sensor_t *sensor); #endif // __OV2640_H__ diff --git a/src/omv/ov2640_regs.h b/src/omv/ov2640_regs.h index 44b973515..8469b2b1f 100644 --- a/src/omv/ov2640_regs.h +++ b/src/omv/ov2640_regs.h @@ -113,7 +113,7 @@ #define AEC 0x10 #define CLKRC 0x11 -#define CLKRC_DOUBLE 0x80 +#define CLKRC_DOUBLE 0x82 #define CLKRC_DIVIDER_MASK 0x3F #define COM10 0x15 diff --git a/src/omv/sensor.c b/src/omv/sensor.c index fee929cca..356661cb6 100644 --- a/src/omv/sensor.c +++ b/src/omv/sensor.c @@ -389,6 +389,9 @@ int sensor_init() switch (sensor.chip_id) { #if (OMV_ENABLE_OV2640 == 1) case OV2640_ID: + if (extclk_config(OV2640_XCLK_FREQ) != 0) { + return -3; + } init_ret = ov2640_init(&sensor); break; #endif // (OMV_ENABLE_OV2640 == 1)