|
在学习STM32F407的照相机接口时遇到了个问题,我用的是MDK开发环境 ,JLINK仿真 ,相机接口通过三根线来驱动 PIXCLK点时钟 HVSYNC行同步信号 VSYNC场同步信号 ,在编译下载仿真时在HVSYNC和VSYNC 对应的中断都响应都能进入,但就是DMA的中断没有被触发,我看了下参考手册,发现需要DCMI接口接收到数据后通知DMA需要DCMI_CaptureCmd(ENABLE); 来设置 CR寄存器的CAPTURE 位!但运行后还是没有进DMA的传送完毕中断void DMA2_Stream1_IRQHandler(void);并且DMA需要传送的目地地址的内容也未改变,我觉得是DCMI接口能响应中断,说明能安外部的触发信号运行,但DMA为何没有被起动传送数据!求教!下面为代码
void Dcmi_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
DCMI_InitTypeDef DCMI_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/*** Configures the DCMI to interface with the OV2640 camera module ***/
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI, ENABLE); /* 使能 DCMI 时钟 */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); /* 使能 DMA2 时钟 */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC, ENABLE); /* 使能 DCMI GPIOs 时钟 */
/*** Configures the DCMI GPIOs to interface with the OV2640 camera module ***/
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
/* DCMI GPIO configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
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);
/* DCMI configuration */
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_Low; //帧同步下沿
DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_Low; //水平同步下沿
DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame; //整个帧图像
DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b; //每次数据8位
DCMI_Init(&DCMI_InitStructure);
/* Configures the DMA2 to transfer Data from DCMI */
DMA_DeInit(DMA2_Stream1);
while (DMA_GetCmdStatus(DMA2_Stream1) != DISABLE)
{
}
DMA_InitStructure.DMA_Channel = DMA_Channel_1;
DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS; //照相机接口数据
DMA_InitStructure.DMA_Memory0BaseAddr =(uint32_t)&imgdata_buffer;//FSMC_LCD_ADDRESS;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; //设备到内存
DMA_InitStructure.DMA_BufferSize = 16; //432;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; //设备端一次传送4个字节32位
DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream1, &DMA_InitStructure);
/* Enable the DMA Stream IRQ Channel */
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);
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);
/* Enable DMA Stream Transfer Complete interrupt */
/* Insert 100ms delay: wait 100ms */
///////////////////////////////////////////////////////////////////////////////////
}
在MAIN中起动DCMI 和DMA
DMA_ITConfig(DMA2_Stream1, DMA_IT_TCIF1, ENABLE);
DCMI_ITConfig(DCMI_IT_VSYNC,ENABLE);
DCMI_ITConfig(DCMI_IT_LINE,ENABLE);
DMA_Cmd(DMA2_Stream1, ENABLE);
DCMI_Cmd(ENABLE);
DCMI_CaptureCmd(ENABLE);
DCMI相机接口能进中断,而DMA好像没被起动
。 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|