|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
我通过探索者板子的DCMI接口连接ov7670无FIFO模块,开启DMA传输数据。根据手册DCMI在起接收到32位数据时,会自动发出DMA请求。现在我在硬件调试的时候发现在DCMI的DR寄存器中没有数值 。然后不管是DMA的接受完成中断还是DCMI的行中断都无法进入。程序会一直卡在 while (DMA_GetFlagStatus(DMA2_Stream1,DMA_FLAG_TCIF1)==RESET)这句话这里,就是说DMA的传输一直没有完成。但是我又通过 DCMI_DMA_Init(data.color,1,DMA_MemoryDataSize_Word,DMA_MemoryInc_Disable );这句话得到了一个数据。以下是我的程序,希望大神指导一下。 |
- void DCMI_IRQHandler(void)
- {
- if(DCMI_GetITStatus(DCMI_IT_LINE)==SET)//捕获到一行图像
- {
- DCMI_ClearITPendingBit(DCMI_IT_FRAME);//清除行中断
- LED0 = !LED0;
- // PicHand();
- }
- }
- void DMA2_Stream1_IRQHandler (void)
- {
- if(DMA_GetITStatus(DMA2_Stream1,DMA_IT_TCIF1) == SET)
- {
- DMA_ClearITPendingBit(DMA2_Stream1,DMA_IT_TCIF1);
- LED1 = !LED1;
- // PicHand();
- }
- }
-
- //DCMI DMA配置
- //DMA_Memory0BaseAddr:存储器地址 将要存储摄像头数据的内存地址(也可以是外设地址)
- //DMA_BufferSize:存储器长度 0~65535
- //DMA_MemoryDataSize:存储器位宽
- //DMA_MemoryDataSize:存储器位宽 @defgroup DMA_memory_data_size :DMA_MemoryDataSize_Byte/DMA_MemoryDataSize_HalfWord/DMA_MemoryDataSize_Word
- //DMA_MemoryInc:存储器增长方式 @defgroup DMA_memory_incremented_mode /** @defgroup DMA_memory_incremented_mode : DMA_MemoryInc_Enable/DMA_MemoryInc_Disable
- void DCMI_DMA_Init(u32 DMA_Memory0BaseAddr,u16 DMA_BufferSize,u32 DMA_MemoryDataSize,u32 DMA_MemoryInc)
- {
- DMA_InitTypeDef DMA_InitStructure;
-
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2,ENABLE);//DMA2时钟使能
- DMA_DeInit(DMA2_Stream1);
- while (DMA_GetCmdStatus(DMA2_Stream1) != DISABLE){}//等待DMA2_Stream1可配置
-
- /* 配置 DMA Stream */
- DMA_InitStructure.DMA_Channel = DMA_Channel_1; //通道1 DCMI通道
- DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&DCMI->DR;//外设地址为:DCMI->DR
- DMA_InitStructure.DMA_Memory0BaseAddr = DMA_Memory0BaseAddr;//DMA 存储器0地址
- DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;//外设到存储器模式
- DMA_InitStructure.DMA_BufferSize = DMA_BufferSize;//数据传输量
- DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//外设非增量模式
- DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc;//存储器增量模式
- DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;//外设数据长度:32位
- DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize;//存储器数据长度
- DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;// 使用循环模式
- DMA_InitStructure.DMA_Priority = DMA_Priority_High;//高优先级
- DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; //FIFO模式
- DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;//使用全FIFO
- DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;//外设突发单次传输
- DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;//存储器突发单次传输
- DMA_Init(DMA2_Stream1, &DMA_InitStructure);//初始化DMA Stream
-
- }
- //DCMI初始化
- void My_DCMI_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- NVIC_InitTypeDef NVIC_InitStructure;
-
-
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOG, ENABLE);//使能GPIOA B C E 时钟
- RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI,ENABLE);//使能DCMI时钟
- //PA4/6初始化设置
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_6;//PA4/6 复用功能输出
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; //复用功能输出
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
- GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化
-
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_6;// PB6/7 复用功能输出
- GPIO_Init(GPIOB, &GPIO_InitStructure);//初始化
-
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_11;//PC6/7/8/9/11 复用功能输出
- GPIO_Init(GPIOC, &GPIO_InitStructure);//初始化
-
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_6;//PE5/6 复用功能输出
- GPIO_Init(GPIOE, &GPIO_InitStructure);//初始化
-
- GPIO_ResetBits(GPIOC,GPIO_Pin_12 | GPIO_Pin_10); //拉低d8-d13
- GPIO_ResetBits(GPIOB,GPIO_Pin_5);
- GPIO_ResetBits(GPIOD,GPIO_Pin_2);
- GPIO_ResetBits(GPIOF,GPIO_Pin_11);
- GPIO_ResetBits(GPIOG,GPIO_Pin_15);
-
- GPIO_PinAFConfig(GPIOA,GPIO_PinSource4,GPIO_AF_DCMI); //PA4,AF13 DCMI_HSYNC
- GPIO_PinAFConfig(GPIOA,GPIO_PinSource6,GPIO_AF_DCMI); //PA6,AF13 DCMI_PCLK
- GPIO_PinAFConfig(GPIOB,GPIO_PinSource7,GPIO_AF_DCMI); //PB7,AF13 DCMI_VSYNC
- GPIO_PinAFConfig(GPIOC,GPIO_PinSource6,GPIO_AF_DCMI); //PC6,AF13 DCMI_D0
- GPIO_PinAFConfig(GPIOC,GPIO_PinSource7,GPIO_AF_DCMI); //PC7,AF13 DCMI_D1
- GPIO_PinAFConfig(GPIOC,GPIO_PinSource8,GPIO_AF_DCMI); //PC8,AF13 DCMI_D2
- GPIO_PinAFConfig(GPIOC,GPIO_PinSource9,GPIO_AF_DCMI); //PC9,AF13 DCMI_D3
- GPIO_PinAFConfig(GPIOC,GPIO_PinSource11,GPIO_AF_DCMI);//PC11,AF13 DCMI_D4
- GPIO_PinAFConfig(GPIOB,GPIO_PinSource6,GPIO_AF_DCMI); //PB6,AF13 DCMI_D5
- GPIO_PinAFConfig(GPIOE,GPIO_PinSource5,GPIO_AF_DCMI); //PE5,AF13 DCMI_D6
- GPIO_PinAFConfig(GPIOE,GPIO_PinSource6,GPIO_AF_DCMI); //PE6,AF13 DCMI_D7
-
-
- DCMI_DeInit();//清除原来的设置
-
-
- DCMI_InitStructure.DCMI_CaptureMode=DCMI_CaptureMode_SnapShot;//快照模式
- DCMI_InitStructure.DCMI_CaptureRate=DCMI_CaptureRate_All_Frame;//全帧捕获
- DCMI_InitStructure.DCMI_ExtendedDataMode= DCMI_ExtendedDataMode_8b;//8位数据格式
- DCMI_InitStructure.DCMI_HSPolarity= DCMI_HSPolarity_Low;//HSYNC 低电平有效
- DCMI_InitStructure.DCMI_PCKPolarity= DCMI_PCKPolarity_Rising;//PCLK 上升沿有效
- DCMI_InitStructure.DCMI_SynchroMode= DCMI_SynchroMode_Hardware;//硬件同步HSYNC,VSYNC
- DCMI_InitStructure.DCMI_VSPolarity=DCMI_VSPolarity_Low;//VSYNC 低电平有效
- DCMI_Init(&DCMI_InitStructure);
-
-
- DCMI_Cmd(ENABLE); //DCMI使能
-
- DCMI_ITConfig(DCMI_IT_LINE,ENABLE);
- DMA_ITConfig(DMA2_Stream1,DMA_IT_TC,ENABLE);
-
- // NVIC_InitStructure.NVIC_IRQChannel = DCMI_IRQn;
- NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream1_IRQn;
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);//设置系统中断优先级分组1
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;//抢占优先级1
- NVIC_InitStructure.NVIC_IRQChannelSubPriority =0; //子优先级3
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
- NVIC_Init(&NVIC_InitStructure); //根据指定的参数初始化VIC寄存器、
-
- }
复制代码 |
|