ov5640 PLL时钟、图像大小、帧率寄存器配置

不同像素和时钟的ov5640摄像头寄存器配置方法
配置摄像头寄存器,网上没有明说的,参考正点原子的文档进行介绍

像素大小配置

0x3801-0x3807 : 设置ISP大小,0*0-2631*1951
0x3808-0x380B : 设置输出图像大小(hs,vs有效的时钟)
0x3810-0x3813 : 在ISP基础上,偏移多少输出(hs,VS的总时钟)

SCCB_Write(0x3800,0x00); // HS
SCCB_Write(0x3801,0x00); // HS   star 00
SCCB_Write(0x3802,0x00); // VS
SCCB_Write(0x3803,0x00); // VS   star 00
SCCB_Write(0x3804,0x0a); // HW SET_OV5640 +  HE}
SCCB_Write(0x3805,0x3f); // HW SET_OV5640 +  HE}  a3f - 2623
SCCB_Write(0x3806,0x07); // VH SET_OV5640 +  VE}
SCCB_Write(0x3807,0x9f); // VH SET_OV5640 +  VE}  79f - 1951

SCCB_Write(0x3808,0x03); // DVPHO     h'320 --- d'800
SCCB_Write(0x3809,0x20); // DVPHO     h'500 --- d'1280  
SCCB_Write(0x380a,0x01); // DVPVO     h'2d0 --- d'720 
SCCB_Write(0x380b,0xe0); // DVPHO     h'1e0 --- d'480

// 设计帧率计算,下面介绍
u16 total_h_pixel  = 1440 ;  //ov5640 水平总像素大小
u16 total_v_pixel  = 1000 ;  //ov5640 垂直总像素大小

SCCB_Write(0x380c,total_h_pixel >> 8); // HTS   0x07
SCCB_Write(0x380d,total_h_pixel & 0x00FF); // HTS   708  1800   0x08
SCCB_Write(0x380e,total_v_pixel >> 8); // VTS  0x03
SCCB_Write(0x380f,total_v_pixel & 0x00FF); // VTS    3e8  1000  0xe8

PLL时钟配置

0x3035[7:4]系统时钟分频器减慢所有时钟
0x3035[3:0]MIPI的比例分频器MIPI PCLK/SERCLK可以减慢
0x3036[7:0]锁相环乘法器(4-252)4~127范围内可以是任意整数,在128 ~ 252范围内只能是偶数
 
// YUV VGA 30fps, night mode 5fps
// Input Clock = 24Mhz, PCLK = 56MHz
write_i2c(0x3035, 0x11); // PLL   
write_i2c(0x3036, 0x46); // PLL
11 = 0001 0001 - 800K
800K * d'70(h'46= 56M

// input clock 24Mhz, PCLK 42Mhz
write_i2c(0x3035, 0x41); // PLL 
write_i2c(0x3036, 0x69); // PLL  
41 = 0100 0001 => 'h41[7:4] = 6 
24M/6 = 400K 
h'69 = d'105  400K *105 = 42M 

// input clock 24Mhz, PCLK 72Mhz
write_i2c(0x3035, 0x11); // PLL 
write_i2c(0x3036, 0x5a); // PLL  
11 - 800K 
800K * 90(5a) = 72M

帧率计算

**上面偏移后图像大小 1440*1000

50帧: 72M / 50 = 1400 000 --> 1440 * 1000 -> 1208 * 720 * 8bit
30帧: 72M / 30 = 2400 000 --> 3000 * 800 -> 800 * 2 * 480 – 16bits 2 pclk
30帧: 72M / 30 = 2400 000 --> 2400 * 1000 -> 1280 * 720 * 8bit

对于50帧800x480x8bit图像 72M时钟 14401000 设置ILA抓取如下图所示 *
一行href有效时钟800clk,无效时钟640clk, 800+640=1440clk
ov5640 PLL时钟、图像大小、帧率寄存器配置_第1张图片

你可能感兴趣的:(fpga开发,c语言,qt,stm32,arm开发)