cancel
Showing results for 
Search instead for 
Did you mean: 

Use HAL library to read and write SDRAM with DMA

ducommun
Associate II
Posted on June 10, 2014 at 14:59

Hi,

I am searching what I need to add to my project in order to use HAL_SDRAM_Read_DMA.

I don't know where and how to configure the DMA. There is only one example but it doesn't use the DMA.

When I start a transfer, there is no interrupt pending on the DMA controller and the code doesn't call my callback code.

Thanks

#hal-sdram-dma
1 REPLY 1
Posted on June 10, 2014 at 17:15

Hi Christophe,

The SDRAM memory configuration is ensured by the MSP layer function BSP_SDRAM_Init().

It configures the SDRAM device registers in the FMC controller as well as the low layer resources according to the used hardware (CLOCK, GPIO, DMA and NVIC).

You may update this function to change SDRAM flash configuration.

You can follow these steps to read and write SDRAM with DMA: 

In a first step, you configure the DMA to write data to SDRAM memory with fixed configuration. You can set the type of transfer (Mode, burst length, size..) by modifying DMA fields configuration. The end of transfer is handled by DMA stream IRQ handler. 

In a second step, reconfigure the DMA to read the written data from SDRAM in order to check its correctness.

You can choose your own configuration by commenting/uncommenting the defines for undesired/desired configurations in the memory SDRAM, for example to configure the SDRAM data bus width as 32 bits, uncomment the define for the configuration ''FMC_SDRAM_MEM_BUS_WIDTH_16'' in ''stm324x9i_eval_sdram.h'' file.

You can configure the DMA peripheral as follows:

  - DMA stream: DMA2_Stream0

  - DMA channel : DMA_Channel_0

  - Direction: Memory to memory

  - DMA mode: Normal mode

  - Peripheral/Memory Data size: Word

  - Peripheral/Memory burst: INC4

 

Hope that these indications could help you.

With regards.