cancel
Showing results for 
Search instead for 
Did you mean: 

camera project without dma to LCD

victory015
Associate II
Posted on August 12, 2016 at 01:40

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

#camera
15 REPLIES 15
victory015
Associate II
Posted on August 15, 2016 at 14:15

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);

Posted on August 15, 2016 at 15:04

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
victory015
Associate II
Posted on August 16, 2016 at 03:46

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();

}

victory015
Associate II
Posted on August 16, 2016 at 03:57

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);

}

Posted on August 16, 2016 at 04:41

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)
}
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
victory015
Associate II
Posted on August 16, 2016 at 16:53

Thank you for the useful code snippet. Now the interrupt handler

DMA2_Stream1_IRQHandler

gets called after adding

NVIC_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.