cancel
Showing results for 
Search instead for 
Did you mean: 

Pixels in each line are not synchronized

eng23
Senior

Hi,

I'm working on DCMI in snapshot mode and the image that I get from this peripheral is shifted eah line down.

I transfer throught DMA to a memory area in external SRAM. After I convert it to RGB and send to my framebuffer. The camera image has 720p horizontal, so I get only the 480 first pixels, but each line has a constant shift.

I tried to read the addresses that were written in each LineEvent interrupt, but it varies.

Below my inits

  hdcmi.Instance = DCMI;
  hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
  hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
  hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_HIGH;
  hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_HIGH;
  hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
  hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
  hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE;
  hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL;	
  hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD;
  hdcmi.Init.LineSelectMode = DCMI_LSM_ALTERNATE_2;
  hdcmi.Init.LineSelectStart = DCMI_OELS_EVEN;
  if (HAL_DCMI_Init(&hdcmi) != HAL_OK)
  {
    Error_Handler();
  }
 
 
    /* DCMI DMA Init */
    /* DCMI Init */
    hdma_dcmi.Instance = DMA2_Stream1;
    hdma_dcmi.Init.Channel = DMA_CHANNEL_1;
    hdma_dcmi.Init.Direction = DMA_PERIPH_TO_MEMORY;
    hdma_dcmi.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_dcmi.Init.MemInc = DMA_MINC_ENABLE;
    hdma_dcmi.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
    hdma_dcmi.Init.MemDataAlignment = DMA_PDATAALIGN_WORD;
    hdma_dcmi.Init.Mode = DMA_CIRCULAR;
    hdma_dcmi.Init.Priority = DMA_PRIORITY_VERY_HIGH;
    hdma_dcmi.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
    hdma_dcmi.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
    hdma_dcmi.Init.MemBurst = DMA_PBURST_SINGLE;
    hdma_dcmi.Init.PeriphBurst = DMA_PBURST_SINGLE;
    if (HAL_DMA_Init(&hdma_dcmi) != HAL_OK)
    {
      Error_Handler();
    }
 
 
HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)CAMERA_FRAMEBUFFER, 0x0000ff00); //480*272*2/4

If I write the camera framebuffer manually and after convert to RGB and send to TFT it works, so my problem is reading peripheral data.

1 REPLY 1
eng23
Senior

I could fix it. I realised that the data transfered by DMA is not raw video, it has the sync datas like LSC (line start code), LEC (line end code)... according to ITU-R BT.656.

I'm using external sync (HSYNC and VSYNC) and I was expecting that DCMI should remove all this sync data and provide only active video.

Is posible to have only active video? Maybe with Embedded sync?

AN5020 (Digital camera interface (DCMI) for STM32 MCUs) shows this embedded sync, but it doesn't inform about the data available.