Skip to main content
victory015
Associate
August 11, 2016
Question

camera project without dma to LCD

  • August 11, 2016
  • 15 replies
  • 2525 views
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
    This topic has been closed for replies.

    15 replies

    victory015
    Associate
    August 13, 2016
    Posted on August 13, 2016 at 04:43

    is there anyone able to brainstorm on this project?

    victory015
    Associate
    August 14, 2016
    Posted on August 14, 2016 at 15:44

    in reference manual, table 43, it shows DMA2, channel 4, stream 3, is the DMA request of SDIO. So i have the code below. I have a question: what is the memory base address of the DMA structure? Is it the FIFO address of SDIO?

      /* DMA2 Stream3 Configuration */  

      DMA_DeInit(DMA2_Stream3);

      DMA_InitStructure.DMA_Channel = DMA_Channel_4;  

      DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS;

      DMA_InitStructure.DMA_Memory0BaseAddr = 0x40012C80;

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

      DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;

      DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;

      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_Stream3, &DMA_InitStructure);

    victory015
    Associate
    August 14, 2016
    Posted on August 14, 2016 at 16:54

    i think we need to DMA to a memory address from camera

    Tesla DeLorean
    Guru
    August 14, 2016
    Posted on August 14, 2016 at 18:09

    The address given to the DMA controller is exactly the same as the register you'd read/write to if you were transferring data to the peripheral manually. DMA simply automates the same process in the background. Review examples of DCMI and SDIO to see what they use. Only DMA2 is capable of memory-to-memory, or peripheral-to-peripheral type configurations.

    I don't think you can pipe the data directly from the DCMI to the SDIO, the forms and rates of the data don't match well. You're welcome to try, but don't expect much assistance.

    I'd presume you are using an STM32F4, but it helps to be specific.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    victory015
    Associate
    August 15, 2016
    Posted on August 15, 2016 at 04:59

    victory015
    Associate
    August 15, 2016
    Posted on August 15, 2016 at 07:31

    victory015
    Associate
    August 15, 2016
    Posted on August 15, 2016 at 07:36

    victory015
    Associate
    August 15, 2016
    Posted on August 15, 2016 at 11:58

    Thank you for replying. it is stm32f4. I spent 6 hours and i couldn't get the DMA from camera to memory working. Can i declare an array variable and use it as DMA destination address?

    uint32_t buffer[8][64];

    DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS;

    DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t) buffer;

    Thank you.

    Tesla DeLorean
    Guru
    August 15, 2016
    Posted on August 15, 2016 at 13:24

    You would need it to increment the memory address to fill the array. It would also fill rather rapidly. If you need to transfer the data out, you'd want to consider doubling the buffer size, and using the HT and TC interrupts to manage alternate halves of the buffer, so the data doesn't change underneath the portion you are working on.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    victory015
    Associate
    August 15, 2016
    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);