-
GD32F527怎么把OV5640摄像头画面显示在屏幕上 sos
[i=s] 本帖最后由 tyw 于 2024-7-10 08:39 编辑 [/i] 我根据GD32F527的OV2640例程修改之后没有画面显示,各位大神有没有OV5640的例程 [attach]2273290[/attach] [size=2][color=#ffffff][backcolor=purple] tyw 注[/backcolor][/color][/size]
999浏览量 0回复量 关注量 -
GD32W515 DCI ov2640摄像头连续捕获模式采集帧率低的问题
OV2640在800*600分辨率,JPG格式输出,日志信息如下: [12:00:37.591]收←◆[ DEBUG ] ov2640 frame count:32768 [12:00:38.653]收←◆[ DEBUG ] ov2640 frame count:33792 [12:00:39.716]收←◆[ DEBUG ] ov2640 frame count:34816 [12:00:40.780]收←◆[ DEBUG ] ov2640 frame count:34816 [12:00:41.842]收←◆[ DEBUG ] ov2640 frame count:34816 [12:00:42.907]收←◆[ DEBUG ] ov2640 frame count:34816 [12:00:43.971]收←◆[ DEBUG ] ov2640 frame count:34816 [12:00:45.035]收←◆[ DEBUG ] ov2640 frame count:34816 即,将近1S才采集一帧。 用逻辑分析仪测试VSYNC,周期大概在37ms,也就是说,一秒有将近30帧输出(可先排除OV2640寄存器相关配置问题,通过串口将jpeg输出到上位机,查看图片也没有问题)。 只要DCI有中断回调,则打印日志,日志速率在500K左右(不用考虑日志速率过低导致漏帧问题)。 DCI的关键配置代码片段如下(参考官方ov2640例程): [color=#abb2bf][backcolor=rgb(40, 44, 52)][font=Consolas, "][size=16px][color=#dbb979] // dci相关I/O口配置为166MHZ速率[/color] [color=#dbb979] // dci配置[/color] [color=#dbb979] dci_parameter_struct[/color] [color=#db7079]dci_struct[/color]; [color=#db7079]dci_struct[/color].[color=#db7079]capture_mode[/color] [color=#c792ea]=[/color] [color=#d19a66]DCI_CAPTURE_MODE_CONTINUOUS[/color];[color=#7f848e]//DCI_CAPTURE_MODE_SNAPSHOT;[/color] [color=#db7079]dci_struct[/color].[color=#db7079]clock_polarity[/color] [color=#c792ea]=[/color] [color=#d19a66]DCI_CK_POLARITY_RISING[/color]; [color=#db7079]dci_struct[/color].[color=#db7079]hsync_polarity[/color] [color=#c792ea]=[/color] [color=#d19a66]DCI_HSYNC_POLARITY_LOW[/color]; [color=#db7079]dci_struct[/color].[color=#db7079]vsync_polarity[/color] [color=#c792ea]=[/color] [color=#d19a66]DCI_VSYNC_POLARITY_LOW[/color]; [color=#db7079]dci_struct[/color].[color=#db7079]frame_rate[/color] [color=#c792ea]=[/color] [color=#d19a66]DCI_FRAME_RATE_ALL[/color]; // dma配置 [color=#dbb979]dma_multi_data_parameter_struct[/color] [color=#db7079]dma_multi_struct[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]periph_addr[/color] [color=#c792ea]=[/color] ([color=#db7079]uint32_t[/color])[color=#d19a66]DCI_DATA_ADDRESS[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]memory0_addr[/color] [color=#c792ea]=[/color] ([color=#db7079]uint32_t[/color])([color=#db7079]capture[/color][[color=#ebb07a]0[/color]].[color=#db7079]image[/color]); [color=#db7079]dma_multi_struct[/color].[color=#db7079]direction[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_PERIPH_TO_MEMORY[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]number[/color] [color=#c792ea]=[/color] ([color=#d19a66]FRAME_BUFFER_SIZE[/color])[color=#c792ea]>>[/color][color=#ebb07a]2[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]periph_inc[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_PERIPH_INCREASE_DISABLE[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]memory_inc[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_MEMORY_INCREASE_ENABLE[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]periph_width[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_PERIPH_WIDTH_32BIT[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]memory_width[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_MEMORY_WIDTH_32BIT[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]circular_mode[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_CIRCULAR_MODE_DISABLE[/color][color=#bbbbbb],[/color] [color=#db7079]dma_multi_struct[/color].[color=#db7079]priority[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_PRIORITY_HIGH[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]critical_value[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_FIFO_4_WORD[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]memory_burst_width[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_MEMORY_BURST_SINGLE[/color]; [color=#db7079]dma_multi_struct[/color].[color=#db7079]periph_burst_width[/color] [color=#c792ea]=[/color] [color=#d19a66]DMA_PERIPH_BURST_SINGLE[/color]; [color=#db7079]dci_struct[/color].[color=#db7079]interface_format[/color] [color=#c792ea]=[/color] [color=#d19a66]DCI_INTERFACE_FORMAT_8BITS[/color]; // ov2640的XCLK时钟输入(由于硬件接到PA2,只能用PWM输出16M左右的时钟作为OV2640时钟输入) [color=#c792ea] const[/color] [color=#dbb979]timer_parameter_struct[/color] [color=#db7079]timer_init_struct[/color][color=#c792ea]=[/color]{ .[color=#db7079]prescaler[/color] [color=#c792ea]=[/color] [color=#ebb07a]0[/color][color=#bbbbbb],[/color] .[color=#db7079]alignedmode[/color] [color=#c792ea]=[/color] [color=#d19a66]TIMER_COUNTER_EDGE[/color][color=#bbbbbb],[/color] .[color=#db7079]counterdirection[/color] [color=#c792ea]=[/color] [color=#d19a66]TIMER_COUNTER_UP[/color][color=#bbbbbb],[/color] .[color=#db7079]period[/color] [color=#c792ea]=[/color] [color=#ebb07a]180[/color][color=#c792ea]/[/color][color=#ebb07a]32[/color][color=#c792ea]-[/color][color=#ebb07a]1[/color][color=#bbbbbb],[/color] .[color=#db7079]clockdivision[/color] [color=#c792ea]=[/color] [color=#ebb07a]0[/color][color=#bbbbbb],[/color] .[color=#db7079]repetitioncounter[/color] [color=#c792ea]=[/color] [color=#ebb07a]0[/color][color=#bbbbbb],[/color] }; [color=#c792ea]const[/color] [color=#dbb979]timer_oc_parameter_struct[/color] [color=#db7079]timer_oc_init_struct[/color][color=#c792ea]=[/color]{ .[color=#db7079]outputstate[/color] [color=#c792ea]=[/color] [color=#d19a66]TIMER_CCX_ENABLE[/color][color=#bbbbbb],[/color] .[color=#db7079]outputnstate[/color] [color=#c792ea]=[/color] [color=#d19a66]TIMER_CCXN_DISABLE[/color][color=#bbbbbb],[/color] .[color=#db7079]ocpolarity[/color] [color=#c792ea]=[/color] [color=#d19a66]TIMER_OC_POLARITY_HIGH[/color][color=#bbbbbb],[/color] .[color=#db7079]ocnpolarity[/color] [color=#c792ea]=[/color] [color=#d19a66]TIMER_OCN_POLARITY_HIGH[/color][color=#bbbbbb],[/color] .[color=#db7079]ocidlestate[/color] [color=#c792ea]=[/color] [color=#d19a66]TIMER_OC_IDLE_STATE_LOW[/color][color=#bbbbbb],[/color] .[color=#db7079]ocnidlestate[/color] [color=#c792ea]=[/color] [color=#d19a66]TIMER_OCN_IDLE_STATE_LOW[/color][color=#bbbbbb],[/color] }; [color=#61afef]gpio_af_set[/color]([color=#d19a66]GPIOA[/color][color=#bbbbbb],[/color] [color=#d19a66]GPIO_AF_1[/color][color=#bbbbbb],[/color] [color=#d19a66]GPIO_PIN_2[/color]); [color=#61afef]gpio_mode_set[/color]([color=#d19a66]GPIOA[/color][color=#bbbbbb],[/color] [color=#d19a66]GPIO_MODE_AF[/color][color=#bbbbbb],[/color] [color=#d19a66]GPIO_PUPD_PULLUP[/color][color=#bbbbbb],[/color] [color=#d19a66]GPIO_PIN_2[/color]); [color=#61afef]gpio_output_options_set[/color]([color=#d19a66]GPIOA[/color][color=#bbbbbb],[/color] [color=#d19a66]GPIO_OTYPE_PP[/color][color=#bbbbbb],[/color] [color=#d19a66]GPIO_OSPEED_166MHZ[/color][color=#bbbbbb],[/color] [color=#d19a66]GPIO_PIN_2[/color]); [color=#61afef]timer_init[/color]([color=#d19a66]TIMER1[/color][color=#bbbbbb],[/color]([color=#dbb979]timer_parameter_struct[/color][color=#c792ea]*[/color])[color=#c792ea]&[/color][color=#db7079]timer_init_struct[/color]); [color=#61afef]timer_channel_output_mode_config[/color]([color=#d19a66]TIMER1[/color][color=#bbbbbb],[/color][color=#d19a66]TIMER_CH_2[/color][color=#bbbbbb],[/color][color=#d19a66]TIMER_OC_MODE_PWM0[/color]); [color=#61afef]timer_channel_output_config[/color]([color=#d19a66]TIMER1[/color][color=#bbbbbb],[/color][color=#d19a66]TIMER_CH_2[/color][color=#bbbbbb],[/color]([color=#dbb979]timer_oc_parameter_struct[/color][color=#c792ea]*[/color])[color=#c792ea]&[/color][color=#db7079]timer_oc_init_struct[/color]); [color=#61afef]timer_break_disable[/color]([color=#d19a66]TIMER1[/color]); [color=#61afef]timer_channel_output_pulse_value_config[/color]([color=#d19a66]TIMER1[/color][color=#bbbbbb],[/color][color=#d19a66]TIMER_CH_2[/color][color=#bbbbbb],[/color][color=#ebb07a]180[/color][color=#c792ea]/[/color][color=#ebb07a]32[/color][color=#c792ea]-[/color][color=#ebb07a]2[/color]); [color=#61afef]timer_channel_output_state_config[/color]([color=#d19a66]TIMER1[/color][color=#bbbbbb],[/color][color=#d19a66]TIMER_CH_2[/color][color=#bbbbbb],[/color][color=#d19a66]TIMER_CCX_ENABLE[/color]); [color=#61afef]timer_enable[/color]([color=#d19a66]TIMER1[/color]); // DCI连续采集使能 [color=#61afef]dma_channel_enable[/color]([color=#d19a66]DMA1[/color][color=#bbbbbb],[/color][color=#56b6c2]DMA_CH7[/color]); [color=#61afef]dci_capture_enable[/color](); [color=#61afef]dci_enable[/color](); // DCI中断处理代码 [color=#7f848e]/// [/color][color=#c792ea]@brief[/color][color=#7f848e] 拍照中断[/color] [color=#7f848e]/// [/color][color=#c792ea]@param[/color][color=#7f848e] [/color] [color=#c792ea]void[/color] [color=#61afef]DCI_IRQHandler[/color]([color=#c792ea]void[/color]) { [color=#c792ea]int[/color] [color=#db7079]size[/color]; [color=#db7079]size[/color] [color=#c792ea]=[/color] [color=#d19a66]FRAME_BUFFER_SIZE[/color] [color=#c792ea]-[/color] ([color=#61afef]dma_transfer_number_get[/color]([color=#d19a66]DMA1[/color][color=#bbbbbb],[/color][color=#56b6c2]DMA_CH7[/color])[color=#c792ea]<<[/color][color=#ebb07a]2[/color]); [color=#61afef]dci_interrupt_flag_clear[/color]([color=#d19a66]DCI_INT_EF[/color][color=#c792ea]|[/color][color=#d19a66]DCI_INT_OVR[/color]); [color=#7f848e]// 看现在是捕获进哪个缓冲区,必须清DMA的标志,否则会导致无法继续捕获[/color] [color=#61afef]dma_channel_disable[/color]([color=#d19a66]DMA1[/color][color=#bbbbbb],[/color][color=#56b6c2]DMA_CH7[/color]); [color=#61afef]dma_flag_clear[/color]([color=#d19a66]DMA1[/color][color=#bbbbbb],[/color][color=#56b6c2]DMA_CH7[/color][color=#bbbbbb],[/color][color=#d19a66]DMA_FLAG_FTF[/color][color=#c792ea]|[/color][color=#d19a66]DMA_FLAG_HTF[/color]); [color=#c792ea]if[/color]([color=#db7079]capture_active[/color]){ [color=#c792ea]if[/color]([color=#db7079]capture_windex[/color]){ [color=#db7079]capture_windex[/color] [color=#c792ea]=[/color] [color=#ebb07a]0[/color]; [color=#db7079]capture_rindex[/color] [color=#c792ea]=[/color] [color=#ebb07a]1[/color]; }[color=#c792ea]else[/color]{ [color=#db7079]capture_windex[/color] [color=#c792ea]=[/color] [color=#ebb07a]1[/color]; [color=#db7079]capture_rindex[/color] [color=#c792ea]=[/color] [color=#ebb07a]0[/color]; } [color=#db7079]image_size[/color] [color=#c792ea]=[/color] [color=#db7079]size[/color]; [color=#db7079]capture_active[/color] [color=#c792ea]=[/color] [color=#ebb07a]0[/color]; [color=#61afef]dma_memory_address_config[/color]([color=#d19a66]DMA1[/color][color=#bbbbbb],[/color][color=#56b6c2]DMA_CH7[/color][color=#bbbbbb],[/color][color=#d19a66]DMA_MEMORY_0[/color][color=#bbbbbb],[/color]([color=#db7079]uint32_t[/color])[color=#db7079]capture[/color][capture_windex].[color=#db7079]image[/color]); } [color=#61afef]dma_transfer_number_config[/color]([color=#d19a66]DMA1[/color][color=#bbbbbb],[/color][color=#56b6c2]DMA_CH7[/color][color=#bbbbbb],[/color]([color=#d19a66]FRAME_BUFFER_SIZE[/color])[color=#c792ea]>>[/color][color=#ebb07a]2[/color]); [color=#61afef]dma_channel_enable[/color]([color=#d19a66]DMA1[/color][color=#bbbbbb],[/color][color=#56b6c2]DMA_CH7[/color]); // [color=#c792ea]if[/color]([color=#db7079]fn_frame_cb[/color])[color=#db7079]fn_frame_cb[/color]([color=#db7079]size[/color]); } [/size][/font][/backcolor][/color]
835浏览量 1回复量 关注量