stm32f103c8t6串口发送 OV2640的图像,分辨率可选。网络上资料大部分是低分辨率的,这个可以做高分辨率
完整工程打包,包含VB串口显示界面:
https://download.csdn.net/download/fengyuzhe13/87327054https://download.csdn.net/download/fengyuzhe13/87327054
//14fps: JPEG_160x120 JPEG_176x144 JPEG_320x240 JPEG_352x288
//7.5fps: JPEG_640x480 JPEG_800x600
//1.5fps: JPEG_1024x768 JPEG_1024x1024 JPEG_1280x1024 JPEG_1600x1200
//串口发送一字节任意数据,返回一幅图像
#include "stm32f10x.h"
#include <stdio.h>
#include "Delay/Delay.h"
#include "USART/USART.h"
#include "OV2640/dcmi_ov2640.h"
#include "../BMP/BMP.h"
#include "timer.h"
#include "stm32f10x_tim.h"
extern unsigned char VsyncCnt; //场同步标志
extern u32 JpegDataCnt;
//extern u8 JpegBuffer[10240];
extern u8 VsyncActive;
OV2640_IDTypeDef OV2640_Camera_ID;
//定时器3中断服务程序
void TIM3_IRQHandler(void) //TIM3中断
{
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查TIM3更新中断发生与否
{
TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //清除TIMx更新中断标志
USART1_Transmit('Q');
}
}
int main(void)
{
// u16 i = 0;
Delay_Init(72);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE);//使能PB3与PB4
USART1_Init(4500000); //在与VB通讯时可以选用 115200 4500000
NVIC_usart();
// USART_SendString("uart init ok!\r\n");
OV2640_HW_Init(); //IIC初始化
// memset(&OV2640_Camera_ID,0x0,sizeof(OV2640_IDTypeDef));
// USART_SendString("uart IIC ok!\r\n");
OV2640_ReadID(&OV2640_Camera_ID); //读取OV2640ID,测试硬件,依次为:0x7F,0xA2,0x26,0x42
//14fps: JPEG_160x120 JPEG_176x144 JPEG_320x240 JPEG_352x288
//7.5fps: JPEG_640x480 JPEG_800x600
//1.5fps: JPEG_1024x768 JPEG_1024x1024 JPEG_1280x1024 JPEG_1600x1200
OV2640_JPEGConfig(JPEG_1024x768);
//设置自动曝光和白平衡
OV2640_BrightnessConfig(0x20);
OV2640_AutoExposure(2);
OV2640_CaptureGpioInit(); //数据采集引脚初始化
EXTI->IMR &= ~EXTI_Line3; //关闭场同步中断
EXTI->EMR &= ~EXTI_Line3;
EXTI->IMR &= ~EXTI_Line4; //关闭像素同步中断
EXTI->EMR &= ~EXTI_Line4;
Delay_nMS(10); //等待图像输出稳定
EXTI->IMR |= EXTI_Line3; //使能场同步中断,准备下次采集
EXTI->EMR |= EXTI_Line3;
while(1)
{
if(VsyncActive == 2)
{
//封帧格式为:0xAA CMD 0x55
if(get_flag_usart()==1)
{
// TIM3_Int_Init(49999,7199);//10Khz的计数频率,计数到50000为5000ms
set_flag_usart(0);
EXTI->IMR |= EXTI_Line3; //使能场同步中断,准备下次采集
EXTI->EMR |= EXTI_Line3;
//VsyncCnt = 0; //开始下一帧数据采集
}
}
}
}