OV7670在LCD上显示之后出现分屏,效果如下,程序如下,各位大佬求解
extern u8 ov_sta; //Ôúexit.càïÃ涨òå
extern u8 ov_frame; //Ôútimer.càïÃ涨òå
//¸üDÂLCDÏÔê¾
void camera_refresh(void)
{
u32 j;
u16 color;
if(ov_sta==2)
{
LCD_Set_Window(0,0,120,160);
LCD_Scan_Dir(U2D_L2R); //′óéÏμ½ÏÂ,′ó×óμ½óò
LCD_SetCursor(0x00,0x0000); //éèÖÃ1a±êλÖÃ
LCD_WriteRAM_Prepare(); //¿aê¼D′èëGRAM
OV7670_CS=0;
OV7670_RRST=0; //¿a꼸′λ¶áÖ¸Õë
OV7670_RCK=0;
OV7670_RCK=1;
OV7670_RCK=0;
OV7670_RRST=1; //¸′λ¶áÖ¸Õë½áêø
OV7670_RCK=1;
for(j=0;j<19200;j++)
{
GPIOB->CRL=0X88888888;
OV7670_RCK=0;
color=OV7670_DATA; //¶áêy¾Y
OV7670_RCK=1;
color<<=8;
OV7670_RCK=0;
color|=OV7670_DATA; //¶áêy¾Y
OV7670_RCK=1;
GPIOB->CRL=0X33333333;
// if(color<25000) //
// color=0x0000; //
// else //
// color=0xffff; //
LCD_WR_DATA(color);
}
OV7670_CS=1;
OV7670_RCK=0;
OV7670_RCK=1;
EXTI->
R=1<<15; //Çå3yLINE8éÏμÄÖD¶Ï±ê־λ
ov_sta=0; //¿aê¼ÏÂò»′Î2é¼ˉ
ov_frame++;
LCD_Scan_Dir(DFT_SCAN_DIR); //»Ö¸′ĬèÏé¨Ãè·½Ïò
}
}
int main(void)
{
u8 i;
delay_init(); //Ñóê±oˉêy3õê¼»ˉ
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// éèÖÃÖD¶ÏóÅÏ輶·Ö×é2
uart_init(9600);
OV7670_Init();
LED_Init(); //3õê¼»ˉóëLEDᬽóμÄó2¼t½ó¿ú
LCD_Init(); //3õê¼»ˉLCD
if(lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X5510||lcddev.id==0X1963) //Ç¿ÖÆéèÖÃÆáÄ»·Ö±æÂêÎa320*240.òÔÖ§3Ö3.5′ç′óÆá
{
lcddev.width=120; //240
lcddev.height=160; //320
}
usmart_dev.init(72); //3õê¼»ˉUSMART
POINT_COLOR=RED;//éèÖÃ×ÖìåÎaoìé«
LCD_ShowString(60,50,200,200,16,"Mini STM32");
LCD_ShowString(60,70,200,200,16,"OV7670 TEST");
LCD_ShowString(60,90,200,200,16,"ATOM@ALIENTEK");
LCD_ShowString(60,110,200,200,16,"2014/3/27");
LCD_ShowString(60,130,200,200,16,"Use USMART To Set!");
LCD_ShowString(60,150,200,200,16,"OV7670 Init...");
while(OV7670_Init())//3õê¼»ˉOV7670
{
LCD_ShowString(60,150,200,200,16,"OV7670 Error!!");
delay_ms(200);
LCD_Fill(60,150,239,166,WHITE);
delay_ms(200);
}
LCD_ShowString(60,150,200,200,16,"OV7670 Init OK");
delay_ms(1500);
TIM3_Int_Init(10000,7199); //TIM3,10Khz¼ÆêyÆμÂê,1ÃëÖóÖD¶Ï
EXTI15_Init(); //ê1Äü¶¨ê±Æ÷2¶»ñ
OV7670_Window_Set(10,174,120,160); //éèÖÃ′°¿ú // 160 240
OV7670_CS=0;
while(1)
{
camera_refresh(); //¸üDÂÏÔê¾
if(i!=ov_frame) //DS0éá˸.
{
i=ov_frame;
LED0=!LED0;
}
}
}
分屏
extern u8 ov_frame; //Ôútimer.càïÃ涨òå
//¸üDÂLCDÏÔê¾
void camera_refresh(void)
{
u32 j;
u16 color;
if(ov_sta==2)
{
LCD_Set_Window(0,0,120,160);
LCD_Scan_Dir(U2D_L2R); //′óéÏμ½ÏÂ,′ó×óμ½óò
LCD_SetCursor(0x00,0x0000); //éèÖÃ1a±êλÖÃ
LCD_WriteRAM_Prepare(); //¿aê¼D′èëGRAM
OV7670_CS=0;
OV7670_RRST=0; //¿a꼸′λ¶áÖ¸Õë
OV7670_RCK=0;
OV7670_RCK=1;
OV7670_RCK=0;
OV7670_RRST=1; //¸′λ¶áÖ¸Õë½áêø
OV7670_RCK=1;
for(j=0;j<19200;j++)
{
GPIOB->CRL=0X88888888;
OV7670_RCK=0;
color=OV7670_DATA; //¶áêy¾Y
OV7670_RCK=1;
color<<=8;
OV7670_RCK=0;
color|=OV7670_DATA; //¶áêy¾Y
OV7670_RCK=1;
GPIOB->CRL=0X33333333;
// if(color<25000) //
// color=0x0000; //
// else //
// color=0xffff; //
LCD_WR_DATA(color);
}
OV7670_CS=1;
OV7670_RCK=0;
OV7670_RCK=1;
EXTI->PR=1<<15; //Çå3yLINE8éÏμÄÖD¶Ï±ê־λ
ov_sta=0; //¿aê¼ÏÂò»′Î2é¼ˉ
ov_frame++;
LCD_Scan_Dir(DFT_SCAN_DIR); //»Ö¸′ĬèÏé¨Ãè·½Ïò
}
}
int main(void)
{
u8 i;
delay_init(); //Ñóê±oˉêy3õê¼»ˉ
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); // éèÖÃÖD¶ÏóÅÏ輶·Ö×é2
uart_init(9600);
OV7670_Init();
LED_Init(); //3õê¼»ˉóëLEDᬽóμÄó2¼t½ó¿ú
LCD_Init(); //3õê¼»ˉLCD
if(lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X5510||lcddev.id==0X1963) //Ç¿ÖÆéèÖÃÆáÄ»·Ö±æÂêÎa320*240.òÔÖ§3Ö3.5′ç′óÆá
{
lcddev.width=120; //240
lcddev.height=160; //320
}
usmart_dev.init(72); //3õê¼»ˉUSMART
POINT_COLOR=RED;//éèÖÃ×ÖìåÎaoìé«
LCD_ShowString(60,50,200,200,16,"Mini STM32");
LCD_ShowString(60,70,200,200,16,"OV7670 TEST");
LCD_ShowString(60,90,200,200,16,"ATOM@ALIENTEK");
LCD_ShowString(60,110,200,200,16,"2014/3/27");
LCD_ShowString(60,130,200,200,16,"Use USMART To Set!");
LCD_ShowString(60,150,200,200,16,"OV7670 Init...");
while(OV7670_Init())//3õê¼»ˉOV7670
{
LCD_ShowString(60,150,200,200,16,"OV7670 Error!!");
delay_ms(200);
LCD_Fill(60,150,239,166,WHITE);
delay_ms(200);
}
LCD_ShowString(60,150,200,200,16,"OV7670 Init OK");
delay_ms(1500);
TIM3_Int_Init(10000,7199); //TIM3,10Khz¼ÆêyÆμÂê,1ÃëÖóÖD¶Ï
EXTI15_Init(); //ê1Äü¶¨ê±Æ÷2¶»ñ
OV7670_Window_Set(10,174,120,160); //éèÖÃ′°¿ú // 160 240
OV7670_CS=0;
while(1)
{
camera_refresh(); //¸üDÂÏÔê¾
if(i!=ov_frame) //DS0éá˸.
{
i=ov_frame;
LED0=!LED0;
}
}
}
[/mw_shl_code]
一周热门 更多>