AnsweredAssumed Answered

Memory management - DCMI, OV7670, DMA, Grey color

Question asked by Wladimir on Mar 21, 2015

First of all there is worth to mention that I have successful communication with OV7670 camera on STM32F407VG Discovery and I getting QCIF format picture in YCbCr format and sending it via USB to computer as virtual port to display image in Matlab function then. For now I can hold 2x QCIF images in YCrCr format which occupies little more than 100kB of memory.
   My problem is that, I want get only grey format data so that I would store 4x QCIF images using the same memory space, but using only DMA configuration without CPU intervention. According to camera datasheet there is no configuration to get grey scale directly. So I've got grey scale by taking only Luma 'Y' component (which in fact is grey color) and then skipping Chroma 'Cb' and 'Cr' in Matlab which are interleaved in DCMI FIFO as below:


DCMI controller sent request to DMA when it has full 32-bit one register (it has 4-deep FIFO), so there is no opportuinity to get DMA action every second byte to get Luma component in linear way because of DMA request which takes 4 byte long.
So I must deal with data where Luma and Chroma component are and I search for way to save in memory only Luma component byte after byte. Actually I got through different configuration of DMA, but there is no result as I want. It is interesting that when the Peripheral allign size is less then 'Word' then DMA is not working at all.
Current DMA configuration:
      DMA_InitStructure.DMA_Channel = DMA_CHANNEL_1;
      DMA_InitStructure.DMA_PeripheralBaseAddr =  (uint32_t)(&DCMI->DR);
      DMA_InitStructure.DMA_Memory0BaseAddr =  (uint32_t)frame_buffer;
      DMA_InitStructure.DMA_BufferSize = (ROW*COLUMNS*BYTESPERPIX)/4;
        DMA_InitStructure.DMA_MemoryInc = DMA_MINC_ENABLE;
      DMA_InitStructure.DMA_PeripheralDataSize = DMA_PDATAALIGN_WORD;
      DMA_InitStructure.DMA_MemoryDataSize =DMA_MDATAALIGN_BYTE; //<- Even so, there is WORD allign
      DMA_InitStructure.DMA_Mode = DMA_NORMAL;
      DMA_InitStructure.DMA_Priority = DMA_PRIORITY_VERY_HIGH;
      DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
      DMA_InitStructure.DMA_MemoryBurst = DMA_MBURST_SINGLE;
      DMA_InitStructure.DMA_PeripheralBurst = DMA_PBURST_SINGLE;

I struggle with finding the way to have direct transfer of Luma component byte after byte to memory.
Now it looks like in this way:

I write to ask whether exists some possibility which I overlooked or I must deal with storing image data as 2-byte per pixel in memory.