完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
`学会了用STM32F407VET6驱动OV7725摄像头模块,这里和大家分享一下经验。
其实话不用说太多,我直接贴上代码。 能下决心来学习的人估计SCCB总线不是什么问题,这里就不多说了 下面是我的OV7725摄像头寄存器配置: {0x32,0x00}, {0x2a,0x00}, {0x11,0x00}, {0x12,0x46},//QVGA RGB565 {0x12,0x46}, {0x42,0x7f}, {0x43,0x80}, {0x44,0x80}, {0x45,0x80}, {0x4d,0x09},//0x09 {0x63,0xe0}, {0x64,0xff}, {0x65,0x20}, {0x66,0x00}, {0x67,0x00}, {0x13,0xf0}, {0x0d,0x81},//PLL {0x0f,0xc5}, {0x14,0x21},//agc {0x22,0xFF},//7f {0x23,0x01}, {0x24,0x34}, {0x25,0x3c}, {0x26,0xa1}, {0x2b,0x00}, {0x6b,0xaa}, {0x13,0xff}, {0x69,0x5d}, {0x90,0x0a},// {0x91,0x01},// {0x92,0x01},// {0x93,0x01}, {0x94,0x5f}, {0x95,0x53}, {0x96,0x11}, {0x97,0x1a}, {0x98,0x3d}, {0x99,0x5a}, {0x9a,0x1e}, {0x9b,0x00},//set luma {0x9c,0x25},//set contrast {0xa7,0x65},//set saturation {0xa8,0x65},//set saturation {0xa9,0x80},//set hue {0xaa,0x80},//set hue {0x9e,0x81}, {0x9f,0x02}, {0xa6,0x06}, {0x7e,0x0c}, {0x7f,0x16}, {0x80,0x2a}, {0x81,0x4e}, {0x82,0x61}, {0x83,0x6f}, {0x84,0x7b}, {0x85,0x86}, {0x86,0x8e}, {0x87,0x97}, {0x88,0xa4}, {0x89,0xaf}, {0x8a,0xc5}, {0x8b,0xd7}, {0x8c,0xe8}, {0x8d,0x20}, {0x4e,0xef}, {0x4f,0x10}, {0x50,0x60}, {0x51,0x00}, {0x52,0x00}, {0x53,0x24}, {0x54,0x7a}, {0x55,0xfc}, {0xac,0xff}, {0x33,0x00}, {0x22,0x99}, {0x23,0x03}, {0x4a,0x00}, {0x49,0x13}, {0x47,0x08}, {0x4b,0x14}, {0x4c,0x17}, {0x46,0x05}, {0x0e,0xf5}, {0x3d,0x82}, {0x0c,0x80}, {0x3e,0xe2}, //一下设置改变图片的输出尺寸 {0x29,0x28},//0x28 {0x2c,0x3c},//0x3c {0x17,0x3f}, {0x18,0x28}, {0x19,0x03}, {0x1a,0x3c} 按照以上设置图片输出是QQVGA(120X160)的图片。 下面是DCMI设置: void DCMI_Configure(void) { GPIO_InitTypeDef GPIO_InitStructure; DCMI_InitTypeDef DCMI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; //step 1 :Enable the clock for the DCMI and associated GPIOs RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOE, ENABLE); RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI,ENABLE); //step 2 :DCMI pins configuration GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9; GPIO_Init(GPIOB,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8/*|GPIO_Pin_9*/|GPIO_Pin_11; GPIO_Init(GPIOC,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_Init(GPIOE,&GPIO_InitStructure); GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_DCMI); //GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOE, GPIO_PinSource1, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOC, GPIO_PinSource11,GPIO_AF_DCMI); DCMI_DeInit();//Çå³ýÔÀ´µÄÉèÖà //step 3 :Declare a DCMI_InitTypeDef structure DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_Continuous;//The received data are transferred continuously DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware;//ÉèÖÃΪӲ¼þͬ²½ DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Rising; //ÉèÖÃÏñËصÄʱÖÓÔÚÉÏÉýÑؼ¤»î DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_High; //Ö¸¶¨´¹Ö±Í¬²½ÐźÅÊÇÔڸߵçƽµÄʱºò¹¤×÷ DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_Low; //Ö¸¶¨Ë®Æ½Í¬²½ÐźÅÊÇÔڸߵçƽµÄʱºò¹¤×÷ DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame;//ÉèÖÃͼÏñÖ¡²¶»ñµÄƵÂÊΪ²¶»ñÈ«²¿Ö¡ //Êý¾ÝдÈëÒº¾§ÆÁËÙ¶ÈÌ«¿ì£¬Òº¾§ÆÁ½ÓÊܲ»ÁË DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b;//Ö¸¶¨ÏñËØÊý¾ÝµÄ¿í¶ÈΪ8λ //step 4 :Initialize the DCMI interface DCMI_Init(&DCMI_InitStructure); DCMI_Cmd(ENABLE); NVIC_InitStructure.NVIC_IRQChannel = DCMI_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); DCMI_ITConfig(DCMI_IT_FRAME,ENABLE);//¿ªÆôÖ¡ÖÐ¶Ï //step 5 :Configure the DMA2_Stream1 channel1 to transfer Data from DCMI DR register to the destination memory buffer DCMI_DMA_Init((u32)&image,19200,DMA_MemoryDataSize_HalfWord,DMA_MemoryInc_Enable); //DMA_Cmd(DMA2_Stream1,ENABLE); //step 6 :Enable DCMI interface //DCMI_Start(); } 输出的图片暂时存储在地址为image的缓冲区中。这里考虑到F407VET6的存储不是很大所以用了QQVGA分辨率图片输出。如果直接用液晶屏显示的话也可以设置成QVGA。 下面是DCMI的中断函数和图片显示代码: void DCMI_IRQHandler(void) { //u16 i; //LCD_open_windows(0,0,320,240); DCMI_Stop(); DCMI_ClearITPendingBit(DCMI_IT_FRAME); a=1; //DCMI_Stop(); //printf("OK "); //DCMI_Start(); } while(1) { if(a) { LCD_open_windows(80,60,160,120); for(i=0;i<19200;i++) { LCD_WR_Data(image[i]); } DCMI_Start(); } 图片显示位于主函数中,a是一个信号量。 ` |
|
相关推荐
|
|
我用的野火的f1板子
想用ov7725改变输出分辨率 改了寄存器的那几个参数 lcd也做了相应的改变 但是显示出来是乱码 这是怎么回事啊 |
|
|
|
|
|
1906 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
1027 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
1436 浏览 1 评论
LL库F030进行3个串口收发,2个串口为232,一个为485,长时间后,会出现串口1停止运行,另外两个正常,只有重启复原
1879 浏览 1 评论
566 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-17 17:12 , Processed in 0.574348 second(s), Total 73, Slave 53 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号