完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
发现代码,,能够进入DCMI读完的中断,发回DCMI数据寄存器是有数据的,但是DMA读回来的数据全是0,,就解救
void Camera_DMA_Init() { DMA_InitTypeDef DMA_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); DMA_DeInit(DMA2_Stream1); DMA_InitStructure.DMA_Channel = DMA_Channel_1; DMA_InitStructure.DMA_PeripheralBaseAddr = 0x50050028; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)(&pixel_data); DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize =6000; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize= DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; DMA_InitStructure.DMA_FIFOThreshold =DMA_FIFOThreshold_1QuarterFull; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream1, &DMA_InitStructure); DMA_Cmd(DMA2_Stream1, ENABLE); } void DCMI_GPIO_Init(){ GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC, ENABLE); /* 使能 DCMI GPIOs 时钟 */ GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_DCMI); //DCMI_HSYNC GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_DCMI); //DCMI_PIXCLK 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(GPIOB, GPIO_PinSource6, GPIO_AF_DCMI); //DCMI_D5 GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_DCMI); //DCMI_VSYNC GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_DCMI); //DCMI_D6 GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_DCMI); //DCMI_D7 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_6; 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_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 ; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_11 ; GPIO_Init(GPIOC, &GPIO_InitStructure); } void Camera_DCMI_Init(){ DCMI_InitTypeDef DCMI_InitStructure; DCMI_GPIO_Init(); DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_Continuous; // DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware; //嵌入式 DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Falling ; //下降沿 DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_High; // DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_Low; // DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame; //帧捕捉频率 DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b;//指定数据宽度 DCMI_Init(&DCMI_InitStructure); RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI, ENABLE); } void NIVC_config() { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = DCMI_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); //DCMI_ITConfig(DCMI_IT_VSYNC, ENABLE); //DCMI_ITConfig(DCMI_IT_LINE, ENABLE); DCMI_ITConfig(DCMI_IT_FRAME, ENABLE); // DCMI_ITConfig(DCMI_IT_OVF, ENABLE); //DCMI_ITConfig(DCMI_IT_ERR, ENABLE); NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); DMA_ITConfig(DMA2_Stream1, DMA_IT_TC, ENABLE); DMA_ITConfig(DMA2_Stream1, DMA_IT_TCIF1, ENABLE); } void Ov7620_Init() { Camera_DCMI_Init(); Camera_DMA_Init(); NIVC_config(); } int main(void) { UART2_Init(); Ov7620_Init(); DCMI_Cmd(ENABLE); delayms(); delayms(); DCMI_CaptureCmd(ENABLE); while (1) { if(DCMI_flag==1) //成功捕捉一帧图像 { DCMI_flag=0; for(pixel_cnt=0;pixel_cnt<12672;pixel_cnt++) { USART_SendData(USART2,pixel_data[pixel_cnt]); delayms(); delayms(); USART_SendData(USART2,DCMI_ReadData());//只发送其低八位数据 delayms(); delayms(); } } } } |
|
相关推荐
3 个讨论
|
|
跟踪程序一步一步调试吧,
|
|
|
|
|
|
你正在撰写讨论
如果你是对讨论或其他讨论精选点评或询问,请使用“评论”功能。
1187 浏览 0 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
1122 浏览 2 评论
2223 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
1311 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
1735 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-27 20:12 , Processed in 0.469815 second(s), Total 41, Slave 34 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号