STM32F767 DCMI DMA image data mis-aligned
Hi,
I am working on a project using STM32F767 to collect image data from a MT9p031 sensor. The camera runs in snapshot mode, image data is stored in external SDRAM (bank2, address from 0xd0000000). After image is collected I send the image data through USB VCP to PC.
When I test the image data with sensor's internal test pattern, I see the collected image is in a strange misaligned way. the image seems scrolled over both horizontally and vertically.
I am using stm32CubeMX to generate MCU config.
The image size I am testing with is quite big so DMA is working in double buffer mode. in cubeMX the DCMI DMA fifo is enabled. below is DCMI init config:
hdcmi.Instance = DCMI;
hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_FALLING;
hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_LOW;
hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW;
hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_12B;
hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE;
hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL;
hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD;
hdcmi.Init.LineSelectMode = DCMI_LSM_ALL;
hdcmi.Init.LineSelectStart = DCMI_OELS_ODD;
/* 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_MDATAALIGN_WORD;
hdma_dcmi.Init.Mode = DMA_NORMAL;
hdma_dcmi.Init.Priority = DMA_PRIORITY_HIGH;
hdma_dcmi.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
hdma_dcmi.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_dcmi.Init.MemBurst = DMA_MBURST_INC4;
hdma_dcmi.Init.PeriphBurst = DMA_PBURST_SINGLE;and I am using HAL functions to start DMA like below:
void IMAGE_Capture(uint16_t *addr)
{
uint32_t wd_size = IMAGE_Get_WordSize(image_roi_width, image_roi_height);
HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)addr, wd_size);
CAMERA_Shoot(image_exp_time_100us);
while(!DCMICompleteFlg){}
DCMICompleteFlg = 0;
}After quite many different tests it seems to me that DMA is not storing the DCMI received data in right address. the circulation scheme has got some order incorrectly. But I do not have to much idea on further debugging / correct this issue.
Could anyone suggest me what the problem is? Thank a lot
hw
