AnsweredAssumed Answered

Dma external memory problem

Question asked by king.janer on Nov 13, 2014
Latest reply on Nov 13, 2014 by karpavicius.linas
i want to transfer my src array to external memory, but i could transfer only first member of my array (0x01) to GPIO ports and hold, where is other 9 members? :( what can i do?

001.#define SRAM_BANK_ADDR      ((uint32_t)0x60000000)
002.#define BUF_SIZE            ((uint32_t)0x10)
003. 
004.const uint32_t src[BUF_SIZE]= {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 0x08, 0x09, 0x10}
005. 
006.DMA_HandleTypeDef dmaHandleSram;
007. 
008.void dmaInit(void)
009.{
010.    dmaHandleSram.Init.Channel              =DMA_CHANNEL_0;            
011.    dmaHandleSram.Init.Direction                =DMA_MEMORY_TO_MEMORY; 
012.    dmaHandleSram.Init.PeriphInc                =DMA_PINC_ENABLE;              
013.    dmaHandleSram.Init.MemInc               =DMA_MINC_ENABLE;          
014.    dmaHandleSram.Init.PeriphDataAlignment      =DMA_PDATAALIGN_WORD;              
015.    dmaHandleSram.Init.MemDataAlignment             =DMA_MDATAALIGN_WORD;          
016.    dmaHandleSram.Init.Mode                 =DMA_NORMAL;                   
017.    dmaHandleSram.Init.Priority                 =DMA_PRIORITY_HIGH;        
018.    dmaHandleSram.Init.FIFOMode             =DMA_FIFOMODE_DISABLE;     
019.    dmaHandleSram.Init.FIFOThreshold            =DMA_FIFO_THRESHOLD_FULL;  
020.    dmaHandleSram.Init.MemBurst             =DMA_MBURST_SINGLE;        
021.    dmaHandleSram.Init.PeriphBurst              =DMA_PBURST_SINGLE;        
022.     
023.    //Select the DMA instance to be used for the transfer : DMA2_Stream0
024.    dmaHandleMem2Sram.Instance = DMA2_Stream0;
025. 
026.    //Select Call-backs functions called after Transfer complete and Transfer error
027.    dmaHandleMem2Sram.XferCpltCallback  = dmaComplete;
028.    dmaHandleMem2Sram.XferErrorCallback = dmaError;
029. 
030.    //Initialize the DMA stream
031.    if(HAL_DMA_Init(&dmaHandleSram) != HAL_OK)
032.    {
033.        Error_Handler();    //Initialization Error
034.    }
035. 
036.    //Configure NVIC for DMA transfer complete/error interrupts
037.    HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0);
038.    HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
039.     
040. 
041.            __DMA2_CLK_ENABLE();
042. 
043.    //Initialize the DMA stream
044.    if(HAL_DMA_Init(&dmaHandleSram) != HAL_OK)
045.    {
046.        Error_Handler();    //Initialization Error
047.    }
048. 
049. 
050.    HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 0, 0);
051.    HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
052. 
053.            if(HAL_DMA_Start_IT(&dmaHandleSram, (uint32_t)src, (uint32_t)0X60000000, size) != HAL_OK)
054.    {
055.        Error_Handler();    //Initialization Error
056.    }
057.}
058. 
059.void fmcSramInit(void)
060.{
061.    SRAM_HandleTypeDef hsram;
062.    FMC_NORSRAM_TimingTypeDef SRAM_Timing;
063. 
064.    //SRAM Configuration
065.    hsram.Instance  = FMC_NORSRAM_DEVICE;
066.    hsram.Extended  = FMC_NORSRAM_EXTENDED_DEVICE;
067. 
068.    SRAM_Timing.AddressSetupTime        = 1;                               
069.    SRAM_Timing.AddressHoldTime         = 1;                               
070.    SRAM_Timing.DataSetupTime           = 1;                               
071.    SRAM_Timing.BusTurnAroundDuration   = 0;
072.    SRAM_Timing.CLKDivision             = 5;                               
073.    SRAM_Timing.DataLatency             = 0;                               
074.    SRAM_Timing.AccessMode              = FSMC_ACCESS_MODE_A;              
075. 
076.    hsram.Init.NSBank           = FSMC_NORSRAM_BANK1; // 0x60000000            
077.    hsram.Init.DataAddressMux       = FSMC_DATA_ADDRESS_MUX_DISABLE;       
078.    hsram.Init.MemoryType           = FSMC_MEMORY_TYPE_PSRAM;          
079.    hsram.Init.MemoryDataWidth      = FSMC_NORSRAM_MEM_BUS_WIDTH_16;
080.    hsram.Init.BurstAccessMode      = FSMC_BURST_ACCESS_MODE_ENABLE;
081.    hsram.Init.WaitSignalPolarity       = FSMC_WAIT_SIGNAL_POLARITY_HIGH;  
082.    hsram.Init.WrapMode         = FSMC_WRAP_MODE_DISABLE;
083.    hsram.Init.WaitSignalActive     = FSMC_WAIT_TIMING_BEFORE_WS;
084.    hsram.Init.WriteOperation       = FSMC_WRITE_OPERATION_ENABLE;
085.    hsram.Init.WaitSignal           = FSMC_WAIT_SIGNAL_DISABLE;
086.    hsram.Init.ExtendedMode     = FSMC_EXTENDED_MODE_DISABLE;      
087.    hsram.Init.AsynchronousWait     = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
088.    hsram.Init.WriteBurst           = FSMC_WRITE_BURST_ENABLE;
089. 
090.    __FSMC_CLK_ENABLE();
091. 
092.    //Initialize the SRAM controller
093.    if(HAL_SRAM_Init(&hsram, &SRAM_Timing, &SRAM_Timing) != HAL_OK)
094.    {
095.        //Initialization Error
096.        Error_Handler();
097.    }
098. 
099.}
100. 
101.void FSMC_GPIOInit(void)
102.{
103.    GPIO_InitTypeDef GPIO_InitStructure;
104. 
105.    //Enable GPIOD and GPIOE clock
106.    __GPIOD_CLK_ENABLE();
107.    __GPIOE_CLK_ENABLE();
108.  
109.    //Setup for output pins
110.    GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
111.    GPIO_InitStructure.Pull = GPIO_PULLUP;
112.    GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
113.    GPIO_InitStructure.Alternate = GPIO_AF12_FSMC;
114.  
115.  
116.    // D0=PD14 D1=PD15 D2=PD0 D3=PD1 D4=PE7 D5=PE8 D6=PE9 D7=PE10 NOE=PD4 NWE=PD5 NWAIT=PD6 CLKOUT=PD3
117.    //Configure PortD pins for us as FSMC output pins
118.    GPIO_InitStructure.Pin = GPIO_PIN_14 | GPIO_PIN_15 | GPIO_PIN_3 | GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |  GPIO_PIN_3;
119.    HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
120.    GPIO_InitStructure.Pin = GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10;
121.    HAL_GPIO_Init(GPIOE, &GPIO_InitStructure); 
122.}

best regards

Outcomes