|
本例程,是通过stm32中断获取摄像头数据,只获取了Y数据存于数组中,而且因为SRAM内存不够只取部分数据显示LCD屏,成像没问题不过还是有点慢,效果是能看出来一帧一帧图像刷,猜测有很大原因是摄像头数据写入LCD屏RAM速度慢,可能还有其他解决办法吧,本人实力有限,那话不多说了,直接给代码,这是主函数代码
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f10x.h"
- #include <stdio.h>
- #include "delay.h"
- #include "usart.h"
- #include "GC2155.h"
- #include "SCCB.h"
- #include "stm32f10x_flash.h"
- #include "lcd.h"
- u8 display[62400]={0};
- void EXTI15_10_IRQHandler(void) //VSYNC --- PG15
- {
- unsigned short i;
-
- if(EXTI->PR & 0x08000)//发生了场中段
- {
- EXTI->PR |= 1<<15; //在该位写1清清除PG15中断
- EXTI->IMR &= 0<<15; //屏蔽PG15中断
- for(i = 0;i < 1000;i++);
- TimerCnt2=0;
- //初始化DMA
- EXTI->IMR |= 1<<14; //开行中断
-
- }
- else
- {
- //启动DMA传输,每个PCLK下降沿触发DAM传输
-
- if(EXTI->PR & 0x04000) //发生行中段
- {
- //while(!(GPIOG->IDR&0x0400)); //下降沿触发数据获取
-
- for(i=0;i<480;i++)
- {
- if((i+1)%2)
- {
- display[TimerCnt2]=(GPIOC->IDR&0xff);
- TimerCnt2++;
- }
- }
-
-
- if(TimerCnt2>=62400) //判断是否写完,写完则屏蔽中断
- {
- EXTI->IMR &= 0<<14;
- EXTI->IMR &= 0<<15; //屏蔽PG15中断
- }
- EXTI->PR=1<<14; //清除行中段
- }
-
- }
-
- }
- int main(void)
- {
- u16 R,G,B,Y;
- u16 i;
- i=0;
-
- delay_init();
- uart_init(115200);
- //TIM3_Int_Init(999,71);//1MHZ的计数频率,计数到1000为1ms
- LCD_Init();
- LCD_WriteRAM_Prepare();
-
- delay_ms(100);
- while(1!=OV7670_init()) ;
- OV7670_GPIO_CONTRL_CONFIG();
- NVIC_Configuration();
-
- while(1)
- {
- if(TimerCnt2==62400)
- {
- LCD_Clear(0xffff);
- for(i=0;i<62400;i++)
- {
- Y=(display[i]&0xff);
- Y<<=8;
-
- R=Y&0xf800;
- B=Y>>11;
- Y>>=5;
- G=Y&0x07e0;
-
- LCD_WriteRAM(R+G+B);
- }
- i=0;
- TimerCnt2=0;
- EXTI->IMR |= 1<<15;
- }
- }
- }
复制代码
只有代码资料,摄像头资料你们上官网,或其他网站都可以搜到
|
评分
-
查看全部评分
|