AnsweredAssumed Answered

STM32F407, DCMI (using DMA) data transfer to External SRAM Problem

Question asked by Iliuhin.Mihai on Dec 12, 2016
Latest reply on Jun 17, 2017 by Avner Gidron



Small Introduction:

Generally speaking, I want to get data from OV9655 camera using DCMI interface with DMA and store the incoming data into External SRAM, afterwards I want to read the stored Data from external SRAM, convert it to an .bmp format and send the image to SD Card, no rocket science.


Problem Description (I use HAL library and custom PCB board) :

After the configuration of DCMI, FSMC,DMA,SDIO with the help of CubeMx (see attachments for configuration code), I was able to receive an image of small size (160x120) from the OV9655 camera  and store it to SD card (2gb), but this works correctly only if i use STM32F407ZGTx internal memory ( uint16_t internalMEM_Buff [160 x 120] ) .


The problem appears when i try to send the incoming data from DCMI DMA to external SRAM ( S62WV5128BLL-55HLI ). In debugging mode i receive an interrupt from DMA and i'm able to jump into function DMA2_Stream7_IRQHandler(), but afterwards, when i try to read what was stored into external SRAM, there is just garbage (random numbers/data), so basically nothing gets written to external SRAM.

So below i described my problem approach. 


My Problem Approach (No solution yet) 
Therefore here are the steps I followed to see where exactly is the problem:


1. First thing, I used the internal memory of STM32F407ZGTx chip to receive a small resolution image 160x120 from the camera and i used the following function:


HAL_DCMI_Start_DMA(&hdcmi, (uint32_t) DCMI_MODE_SNAPSHOT, (uint32_t) internalMEM_Buff, 19200);


* internalMEM_Buff - represents an unsigned int array of length 19200 (160 x 120).

I receive the correct data/image from the camera, this leads me to the thought that DCMI interface and Camera (OV9655) are configured correctly.  


2. The second step was to test if in general I can write/read something to/from external SRAM, therefore I did a simple function that writes to the SRAM a specific data pattern i can recognize. I used the following functions for test purposes:



HAL_SRAM_Write_8b(&hsram2, (uint32_t*)0x60000000, (uint8_t*) writeTestPattern, (uint32_t) sizeof(writeTestPattern)


HAL_SRAM_Read_8b(&hsram2, (uint32_t*)0x60000000, (uint8_t*) readTestPattern, (uint32_t) sizeof(readTestPattern))



When I’m reading the data from “readTestPattern” I’m getting the correct pattern. I even did an data overflow to be sure that I’m writing and reading to/from my external SRAM. So, therefore this leads me to the conclusion that SRAM is also configured correctly.


 3. Therefore my guess is that the problem is related to DCMI DMA and the address I give to the following function when I want data to be stored into external SRAM:

HAL_DCMI_Start_DMA(&hdcmi, (uint32_t) DCMI_MODE_SNAPSHOT, (uint32_t) 0x60000000, 19200)


*But here is the tricky part, I know for sure that the address for FSMC NOR FLASH/SRAM BANK1 has the following address: 0x60000000


So where is my mistake? Can you please give me some ideas / feedback on this.

(Maybe I don’t understand well how HAL works with external SRAM and DMA)


P.s I know people asked a lot of times similar type of questions, but i didn't see somebody using HAL library for these tasks and having this type of problem.

Thank you in advance.