STM32F429接收SAA7113转换出的YUV422视频信号,数据能否完整接收到?

2019-07-21 00:11发布

SAA7113是将PAL制式的模拟视频信号转换成标准ITU656数字信号(YUV422隔行扫描),数据输出时钟是27M,8bit并口输出。有行、场信号。我的目的是从SAA7113传出来的数据中提取出一帧完整的图像,就是不定时的拍一张照片(拍照时间间隔很长)。
请问利用STM32F4的DCMI和DMA能否实现数据 实时 接收并缓存到SDRAM中,这里接收数据时去判断是不是一帧完整的图像,缓存大概两张图像大,后期需要提取图片时从缓存中找出一帧完整的图像。我的想法是不是可行?有没有更好的方法读取一张完整的照片?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
19条回答
ztzjl2010
1楼-- · 2019-07-21 03:29
 精彩回答 2  元偷偷看……
正点原子
2楼-- · 2019-07-21 07:39
当然可以的。
ztzjl2010
3楼-- · 2019-07-21 10:26
原子哥,我配置DCMI跟DMA,配置之后收不到数据。开行、场中断会进中断。然后关所有中断,在主循环里判断DCMI的FIFO是不是有数据,一直无有效数据。最后我把引脚配置成通用输入引脚,分别用PCLK、行、场、引脚中断,都可以进中断。下面是我的配置代码,是不是有问题啊?

[mw_shl_code=c,true]定义的接收地址及缓存,缓存放在SDRAM中,SDRAM测试过、读写数据没问题。 #define DCMI_DR_ADDRESS 0x50050028 #define FSMC_LCD_ADDRESS 0xD0000000//未用开启LCD控制器,这里用做SDRAM首地址 #define BUFFER_SIZE (40960) U32 YUV422BUF1[40960] __attribute__((at(FSMC_LCD_ADDRESS))); U32 YUV422BUF2[40960] __attribute__((at(FSMC_LCD_ADDRESS + (40960 * 4)))); 引脚配置: /*** Configures the DCMI GPIOs to interface with the OV2640 camera module ***/ /* Enable DCMI GPIOs clocks */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE, ENABLE); /* Connect DCMI pins to AF13 */ GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_DCMI);//DCMI_D0 GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_DCMI);//DCMI_D1 GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_DCMI);//DCMI_D2 GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_DCMI);//DCMI_D3 GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_DCMI);//DCMI_D4 GPIO_PinAFConfig(GPIOD, GPIO_PinSource3, GPIO_AF_DCMI);//DCMI_D5 GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_DCMI);//DCMI_D6 GPIO_PinAFConfig(GPIOE, GPIO_PinSource6, GPIO_AF_DCMI);//DCMI_D7[/mw_shl_code] [mw_shl_code=c,true] GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_DCMI);//DCMI_VSYNC GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_DCMI);//DCMI_HSYNC GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_DCMI);//PCLK /* DCMI GPIO configuration */ /* D0..D4(PC6/7/8/9/11) */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_11; 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_InitStructure.GPIO_Mode = GPIO_Mode_IN; // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; // GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; GPIO_Init(GPIOC, &GPIO_InitStructure); /* D5(PD3)*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_Init(GPIOD, &GPIO_InitStructure); /* D6(PB8),VSYNC(PB7)*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_7; GPIO_Init(GPIOB, &GPIO_InitStructure); /* D7(PD3)*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_Init(GPIOE, &GPIO_InitStructure); /* HSYNC(PA4)*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_Init(GPIOA, &GPIO_InitStructure); /* PCLK(PA6) */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); DCMI跟DMA配置 /****************************************************/ DCMI_InitTypeDef DCMI_InitStructure; DMA_InitTypeDef DMA_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; //NVIC /*** Configures the DCMI to interface with the OV2640 camera module ***/ /* Enable DCMI clock */ RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI, ENABLE); /* DCMI configuration */ DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_Continuous; // DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_SnapShot; DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware; DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Falling; // DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_Low; // DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_Low; DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_High; DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_High; DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame; DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b; /* DCMI configuration */ DCMI_Init(&DCMI_InitStructure); [mw_shl_code=c,true] DCMI_ITConfig(DCMI_IT_FRAME, ENABLE);[/mw_shl_code] /* Configures the DMA2 to transfer Data from DCMI */ //Interrupt Init NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = DCMI_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* Enable DMA2 clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); /* DMA2 Stream1 Configuration */ DMA_DeInit(DMA2_Stream1); DMA_InitStructure.DMA_Channel = DMA_Channel_1; DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS; // DMA_InitStructure.DMA_Memory0BaseAddr = FSMC_LCD_ADDRESS; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)YUV422BUF1; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = BUFFER_SIZE; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_DoubleBufferModeConfig(DMA2_Stream1,(uint32_t)&YUV422BUF2,DMA_Memory_0);//DMA_Memory_0; DMA_DoubleBufferModeCmd(DMA2_Stream1,ENABLE); DMA_ITConfig(DMA2_Stream1,DMA_IT_TC,ENABLE); DMA_Init(DMA2_Stream1, &DMA_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); int main(void) { [/mw_shl_code] [mw_shl_code=c,true]        unsigned int i; SDRAM_Init();//SDRAM[/mw_shl_code] [mw_shl_code=c,true]         for(i = 0;i < BUFFER_SIZE;i++)         {              YUV422BUF1 = i;             YUV422BUF2 = BUFFER_SIZE - i;         } [/mw_shl_code] [mw_shl_code=c,true] PORT_Init(); DCMIDMA_Init(); DCMI_Cmd(ENABLE); DMA_Cmd(DMA2_Stream1, ENABLE); while(1) { } }[/mw_shl_code]
ztzjl2010
4楼-- · 2019-07-21 10:46
回复【2楼】正点原子:
---------------------------------
上面是我的配置代码跟SAA7113的时序,HREF是行信号、VREF是场信号
myopen_720
5楼-- · 2019-07-21 15:30
 精彩回答 2  元偷偷看……
ztzjl2010
6楼-- · 2019-07-21 20:57
回复【5楼】myopen_720:
---------------------------------
上升沿下降沿都试过了,效果一样,目前收不到数据,缓存里没数据。行、场、PCLK信号都已经送到单片机引脚,应该能收到数据,至于对不对再谈。还在找原因。

一周热门 更多>