关于ov2640能读出厂家id,但VSYNC,HREF,PCLX,均没有号信输出,是怎么回事啊?

2019-07-20 01:25发布

[mw_shl_code=c,true] [/mw_shl_code] [mw_shl_code=c,true] [/mw_shl_code] [mw_shl_code=c,true] [/mw_shl_code] [mw_shl_code=c,true]#include "stm32f4xx.h" #include "usart.h" #include "sys.h" #include "delay.h" #include "led.h" #include "usmart.h" #include "sccb.h" #include "ov2640.h" #include "exti.h" u32 JPEG_Cnt = 0; extern u32 JpegDataCnt; extern u8 JpegBuffer[10240]; extern u8 VsyncActive; const u16 jpeg_img_size_tbl[][2]= { 176,144, //QCIF 160,120, //QQVGA 352,288, //CIF 320,240, //QVGA 640,480, //VGA 800,600, //SVGA 1024,768, //XGA 1280,1024, //SXGA 1600,1200, //UXGA }; const u8*EFFECTS_TBL[7]={"Normal","Negative","B&W","Redish","Greenish","Bluish","Antique"}; //7?????§ const u8*JPEG_SIZE_TBL[9]={"QCIF","QQVGA","CIF","QVGA","VGA","SVGA","XGA","SXGA","UXGA"}; //JPEG???? 9?????? int main(void) { u32 i; u8 size=3; //??????QVGA 320*240???? u32 jpeglen=0; u8 no=0; uart_init(115200); //???????®???¨??????115200 delay_init(168); //?????????±???? NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//?è????????????????·?×é2 LED_Init(); OV2640_Init(); OV2640_JPEG_Mode(); //JPEG???? OV2640_OutSize_Set(jpeg_img_size_tbl[size][0],jpeg_img_size_tbl[size][1]);//?è?????????? SCCB_WR_Reg(0XFF,0X00); SCCB_WR_Reg(0XD3,30); SCCB_WR_Reg(0XFF,0X01); SCCB_WR_Reg(0X11,0X1); while(1) { for(i=0;i<10;i++) //???ú10????????OV2640×????÷?????¨????°×?????®?à???© { while(OV2640_VSYNC==1); while(OV2640_VSYNC==0); } while(OV2640_VSYNC==1) //????????jpeg???? { LED1=0; while(OV2640_HREF) { LED2=0; while(OV2640_PCLK==0); JpegBuffer[jpeglen]=OV2640_DATA; while(OV2640_PCLK==1); LED2=1; jpeglen++; } LED2=1; no=1; } while(no) { for(i = 0; i < jpeglen; i ++) { USART_SendData(USART1,JpegBuffer); while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); } jpeglen=0; no=0; } } } [/mw_shl_code] [mw_shl_code=c,true] [/mw_shl_code] [mw_shl_code=c,true] [mw_shl_code=c,true]u8 OV2640_Init(void) { u16 i=0; u16 reg; GPIO_InitTypeDef GPIO_InitStructure; //?è??IO //RCC_AHB1PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOG|RCC_APB2Periph_AFIO, ENABLE); //?????à???????±?? //RCC_AHB1Periph_GPIOD RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOG, ENABLE); //?????à???????±?? //VSYNC???????? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//PD6???? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//???¨???????? GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//???? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_SetBits(GPIOD,GPIO_Pin_0); //HREF???? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; //PG14???? //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//???¨???????? GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//???? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_SetBits(GPIOD,GPIO_Pin_1); //PCLK???? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //PB4 ???? ???? //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//???¨???????? GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//???? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_SetBits(GPIOD,GPIO_Pin_2); //POWER ???????? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; //PB3 ???? //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //???? GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì???? GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_SetBits(GPIOB,GPIO_Pin_3); //???????????? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; //PG15???? //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //???? GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì???? GPIO_Init(GPIOG, &GPIO_InitStructure); GPIO_SetBits(GPIOG,GPIO_Pin_15); GPIO_InitStructure.GPIO_Pin = 0xff; //PC0~7 ???? ???? //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//???¨???????? GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//???? GPIO_Init(GPIOE, &GPIO_InitStructure); OV2640_PWDN=0; //POWER ON delay_ms(10); OV2640_RST=0; //????OV2640 delay_ms(10); OV2640_RST=1; //?á?????? SCCB_Init(); //??????SCCB ??IO?? SCCB_WR_Reg(OV2640_DSP_RA_DLMT, 0x01); //??×÷sensor?????÷ SCCB_WR_Reg(OV2640_SENSOR_COM7, 0x80); //?í????OV2640 delay_ms(50); reg=SCCB_RD_Reg(OV2640_SENSOR_MIDH); //?????§??ID ??°??? reg<<=8; reg|=SCCB_RD_Reg(OV2640_SENSOR_MIDL); //?????§??ID ??°??? if(reg!=OV2640_MID) { printf("MID:%d ",reg); return 1; } reg=SCCB_RD_Reg(OV2640_SENSOR_PIDH); //?????§??ID ??°??? reg<<=8; reg|=SCCB_RD_Reg(OV2640_SENSOR_PIDL); //?????§??ID ??°??? if(reg!=OV2640_PID) { printf("HID:%d ",reg); //return 2; } //?????? OV2640,????SXGA·?±???(1600*1200) for(i=0;i<sizeof(ov2640_uxga_init_reg_tbl)/2;i++) { SCCB_WR_Reg(ov2640_uxga_init_reg_tbl[0],ov2640_uxga_init_reg_tbl[1]); } return 0x00; //ok } [/mw_shl_code]

[/mw_shl_code] [mw_shl_code=c,true]void OV2640_JPEG_Mode(void) { u16 i=0; //?è??:YUV422???? for(i=0;i<(sizeof(ov2640_yuv422_reg_tbl)/2);i++) { SCCB_WR_Reg(ov2640_yuv422_reg_tbl[0],ov2640_yuv422_reg_tbl[1]); } //?è??:????JPEG???? for(i=0;i<(sizeof(ov2640_jpeg_reg_tbl)/2);i++) { SCCB_WR_Reg(ov2640_jpeg_reg_tbl[0],ov2640_jpeg_reg_tbl[1]); } }[/mw_shl_code]
[mw_shl_code=c,true]u8 OV2640_ImageWin_Set(u16 offx,u16 offy,u16 width,u16 height) { u16 hsize; u16 vsize; u8 temp; if(width%4)return 1; if(height%4)return 2; hsize=width/4; vsize=height/4; SCCB_WR_Reg(0XFF,0X00); SCCB_WR_Reg(0XE0,0X04); SCCB_WR_Reg(0X51,hsize&0XFF); //?è??H_SIZE????°??? SCCB_WR_Reg(0X52,vsize&0XFF); //?è??V_SIZE????°??? SCCB_WR_Reg(0X53,offx&0XFF); //?è??offx????°??? SCCB_WR_Reg(0X54,offy&0XFF); //?è??offy????°??? temp=(vsize>>1)&0X80; temp|=(offy>>4)&0X70; temp|=(hsize>>5)&0X08; temp|=(offx>>8)&0X07; SCCB_WR_Reg(0X55,temp); //?è??H_SIZE/V_SIZE/OFFX,OFFY?????? SCCB_WR_Reg(0X57,(hsize>>2)&0X80); //?è??H_SIZE/V_SIZE/OFFX,OFFY?????? SCCB_WR_Reg(0XE0,0X00); return 0; } [/mw_shl_code]


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
13条回答
zhuacai
2019-07-21 02:46
[mw_shl_code=c,true]//??????SCCB???? //CHECK OK void SCCB_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);//????GPIOD?±?? //GPIOF9,F10???????è?? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7;//PD6,7 ???ì???? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //PD6,7 ???ì???? GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì???? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//???? GPIO_Init(GPIOD, &GPIO_InitStructure);//?????? GPIO_SetBits(GPIOD,GPIO_Pin_6|GPIO_Pin_7); SCCB_SDA_OUT(); } [/mw_shl_code] [mw_shl_code=c,true]//IO??×÷???? #define SCCB_SCL PDout(6) //SCL #define SCCB_SDA PDout(7) //SDA #define SCCB_READ_SDA PDin(7) //????SDA #define SCCB_ID 0X60 //OV2640??ID [/mw_shl_code]
大哥能发你的代码看看吗?我的邮箱是416954665@qq.com

一周热门 更多>