2016-08-11 04:40 PM
dear all,
I have studied the camera sample project, it uses dma from camera address to LCD memory address. I do not have lcd in my design, so when i run the camera project, i see one whole black image. Is there a way to modify the project so that it uses dma to SD Card address directly? thanks,victor #camera2016-08-15 05:15 AM
Thank you for replying. I am getting all 0x00 in the memory buffer (screenBuffer variable) after the DMA. Is there a DMA setup error? The DMA code is below.
It loos like the all 0x00 problem is independent of using DMA half transfer and DMA transfer complete interrupt.uint8_t screenBuffer[480][160];
/* Configures the DMA2 to transfer Data from DCMI to the LCD ****************/
/* Enable DMA2 clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); /* DMA2 Stream3 Configuration */ DMA_DeInit(DMA2_Stream1); DMA_InitStructure.DMA_Channel = DMA_Channel_1; DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS; DMA_InitStructure.DMA_Memory0BaseAddr = (uint8_t)screenBuffer; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 1; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; 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_Init(DMA2_Stream1, &DMA_InitStructure); DMA_Cmd(DMA2_Stream1, ENABLE);2016-08-15 06:04 AM
Transferring one byte hardly seems like a viable configuration. It needs to describe the transfer buffer in units of the transfer width. These would probably need to be word or half-word, depending on what you have interfaced to the DCMI port.
2016-08-15 06:46 PM
The HT and TC interrupts, where do i manage them ? in stm32f4xx_it.c ?
The stm32f4 camera example has the irq handler as below. Do i create a similar irq handler for DCMI? void SD_SDIO_DMA_IRQHANDLER(void){ /* Process DMA2 Stream3 or DMA2 Stream6 Interrupt Sources */ SD_ProcessDMAIRQ();}2016-08-15 06:57 PM
i may find the code for DCMI TC interrupt. i add the code below to stm32f4 camera example. But the interrupt handler (DMA2_Stream1_IRQHandler) is never called when the blue button is pressed. Please help me !!
DMA_ITConfig(DMA2_Stream1, DMA_IT_TC, ENABLE);void DMA2_Stream1_IRQHandler(void){ DMA_ClearITPendingBit(DMA2_Stream1, DMA_IT_TC); DMA_Cmd(DMA2_Stream1, DISABLE); DMA_Cmd(DMA2_Stream1, ENABLE);}2016-08-15 07:41 PM
Presuming you picked the right DMA, channel and stream...
...
NVIC_Configuration();
...
/* Enable DMA Stream Half / Transfer Complete interrupt */
DMA_ITConfig(DMA2_Stream1, DMA_IT_TC | DMA_IT_HT, ENABLE);
...
//******************************************************************************
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the DMA Stream IRQ Channel */
NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
//******************************************************************************
void DMA2_Stream1_IRQHandler(void)
{
/* Test on DMA Stream Half Transfer interrupt */
if (DMA_GetITStatus(DMA2_Stream1, DMA_IT_HTIF1))
{
/* Clear DMA Stream Half Transfer interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream1, DMA_IT_HTIF1);
// Add code here to process first half of buffer (ping)
}
/* Test on DMA Stream Transfer Complete interrupt */
if (DMA_GetITStatus(DMA2_Stream1, DMA_IT_TCIF1))
{
/* Clear DMA Stream Transfer Complete interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream1, DMA_IT_TCIF1);
// Add code here to process second half of buffer (pong)
}
}
2016-08-16 07:53 AM
Thank you for the useful code snippet. Now the interrupt handler
DMA2_Stream1_IRQHandler
gets called after addingNVIC_Configuration();
I put a breakpoint in
DMA2_Stream1_IRQHandler
. After DMA_Cmd(DMA2_Stream1, ENABLE); the breakpoint keeps getting triggered, which means the DMA_IT_TC interrupt is generated all the time (i only add DMA_IT_TC in DMA_ITConfig). This does not make sense as the camera blue button is not pressed.i have not figured out why.