cancel
Showing results for 
Search instead for 
Did you mean: 

Could anyone explain me how to set DMA param for DCMI camera capture in STM32f4

theparitt
Associate II
Posted on July 25, 2012 at 01:46

Hi, 

        I am cery confuse about how to set DMA parameters. I would like to capture images from camera using DCMI module. I don't understand Burst and BufferSize params of DMA.  I would like to capture QCIF (176x144) YUV 4:2:2 from a camera to an array buffer.  Here is the parameters that I use but it doesn't work..

DMA_InitStructure.DMA_Channel = DMA_Channel_1;

DMA_InitStructure.DMA_PeripheralBaseAddr =  (uint32_t)DCMI_DR_ADDRESS;

DMA_InitStructure.DMA_Memory0BaseAddr =  (uint32_t)frame_buffer;

DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;

DMA_InitStructure.DMA_BufferSize = (176*144)/4;

DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //single register

DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //frame_buffer++;

DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;

DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;

DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;

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;

/* DMA2 IRQ channel Configuration */

DMA_Init(DMA2_Stream1, &DMA_InitStructure);

 Thanks
3 REPLIES 3
theparitt
Associate II
Posted on July 25, 2012 at 01:50

and this is my DCMI config part;

DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b;//bit[11:10]: 8bit-data/pclk

DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame;   //bit[9:8]:   Frame Capture Rate Control

DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_High;           //LOW          //bit[7]:     VSYNC active @low

DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_Low;           //bit[6]:     HSYNC active @high

DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Rising;      //bit[5]:     PCLK at Rising Edge

DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware;     //bit[4]:     use hardware VSYNC/HSYNC

//DCMI_JPEGCmd(ENABLE/DISABLE) bit[3]: JPEG Mode

//bit[2]: Crop mode

DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_Continuous;     //bit[1]:    

//bit[0]:     capture 0:disable/1:enable

DCMI_Init(&DCMI_InitStructure);

stbbrad3
Associate II
Posted on July 25, 2012 at 03:13

Here is what I do with my DMA. I am tranfering alot more data per frame.. but this works for me..

/* DMA Stream Configuration */

DMA_DeInit ( DCMI_DMA_STREAM );

DMA_InitStructure.DMA_Channel = DCMI_DMA_CHANNEL;

DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS;

DMA_InitStructure.DMA_Memory0BaseAddr = DCMI_IMAGE_SRAM_ADDRESS;

DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;

DMA_InitStructure.DMA_BufferSize = 0xffff;//Maximum

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

DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;

DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;

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

DMA_DoubleBufferModeConfig(DMA2_Stream1, DCMI_IMAGE_SRAM_ADDRESS + ( 0xffff * 4 ), DMA_Memory_0);

DMA_DoubleBufferModeCmd(DMA2_Stream1, ENABLE);

I was having issues myself and got some help here on the forums.

Check out these two posts if you interested.

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Some more DCMI problems F207IG&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=452

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/DCMI Issues, looking for insight&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=1400

Hope this helps!

Cheers,

Brad

theparitt
Associate II
Posted on July 25, 2012 at 03:31

Thanks Brads  :)