Here I am trying to move the data at the SRAM location 0x20000010 into the ODR register of the GPIOE of STM32f303. But it is not happening for me(I an not see the data change in the ODR while debugging) . I dont understand why. Can any one help me out in this?


int SRAM_ADDRESS __attribute__((section(".ARM.__at_0x20000010")));  
volatile Task_S_T *Task;
    Task = LCD_FIFO_Peek();

    SRAM_ADDRESS = Task->Data;

        //initialize source and destination arrays
    uint32_t source = 0x20000010;                               // SRAM Starting address where the LCD Task data is loaded
    uint32_t destination = 0x48001014;
  DMA_InitTypeDef   DMA_InitStructure;

  /* Enable DMA1 clock -------------------------------------------------------*/
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);


  DMA_InitStructure.DMA_PeripheralBaseAddr =    (uint32_t)destination;
  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)source;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
  DMA_InitStructure.DMA_BufferSize = 16;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  DMA_Init(DMA1_Channel1, &DMA_InitStructure);

  DMA_Cmd(DMA1_Channel1, ENABLE);
  LCD_Port_Set_Output();    // Just ensure that the LCD port is in output direction on the appropriate pin masks.
  GPIO_SetBits(LCD_BUS_GPIO_PORT, LCD_E_PIN);                   // Toggle Enable pin on.
  GPIO_ResetBits(LCD_BUS_GPIO_PORT, LCD_E_PIN);                 // Toggle Enable pin off.
  • \$\begingroup\$ What exactly are you trying to do? You've defined your data arrays as holding 32 bit words, which won't fit in an 8 bit IO port - and the IO port will only hold one 8-bit byte at a time. \$\endgroup\$ Nov 17, 2014 at 7:25
  • \$\begingroup\$ I am trying to replicate the normal function (please see edit section) using DMA. \$\endgroup\$
    – spp
    Nov 17, 2014 at 8:28
  • \$\begingroup\$ @spp: How do you locate your data at address 0x20000000? I think you should first put your data int a array, just like "uint32_t source[SIZE]", and then set this to the source address, look if it work well. If all works as you expected, then try put the data in absolute address. \$\endgroup\$
    – diverger
    Nov 18, 2014 at 11:33
  • \$\begingroup\$ Which IDE are you using? If is ARM MDK, then if you want to put data in a absolute address, you do need some tricks, have you see this link: keil.com/support/docs/2829.htm? \$\endgroup\$
    – diverger
    Nov 18, 2014 at 11:39
  • \$\begingroup\$ @diverger: You are right and that's how I have put the data in the absolute address just like that only and I verified that using keil's feature to look in to the particular memory address. \$\endgroup\$
    – spp
    Nov 18, 2014 at 17:30

1 Answer 1


I am a bit stuck in that because do not have much knowledge on SRAM and how to access it. can anyone help me out here?

"SRAM" just like the memory on your PC, all your function stacks, and auto variables are located in it. In your code above, the two arrays:

uint32_t source[SIZE]; uint32_t destination[SIZE];

just are allocated in "SRAM", the code your posted, is using DMA to transfer data from array "source" to "destination", and when done, it generate a interrupt.

So, what your need is just locating your data in SRAM, then fire the DMA. If your data need be located at a given address such as "0x??????", the address need be in your SRAM's address. For STM32f303VCT6, the interanl SRAM starts from address 0x20000000, ends on 0x2000A000.

There may be different methods depend on which compiler you are using. For ARM MDK, you can go here: http://www.keil.com/support/docs/2829.htm


If you want to use DMA to transfer data/command from your memory to LCD. You may need:

  1. Put your data/command in the fixed memory location. And you may need to set your LCD control pins, such as A0, enable, etc....
  2. Set the "DMA_PeripheralBaseAddr" to "&GPIOX->ODR", "X" dependent on which GPIO port you are using.
  3. Set "DMA_DIR" to "DMA_DIR_PeripheralDST";
  4. Set "DMA_MemoryBaseAddr" to your data address.
  5. Set the "DMA_BufferSize" to your buffer size. Note:

Specifies the buffer size, in data unit, of the specified Channel. The data unit is equal to the configuration set in DMA_PeripheralDataSize or DMA_MemoryDataSize members depending in the transfer direction.

  1. Set "DMA_PeripheralDataSize" and "DMA_MemoryDataSize" to byte, because your LCD interface is 8 bit.
  2. When using "DMA_M2M_Disable", you need a hardware DMA trigger source, using "DMA_M2M" you can trig the DMA by your code, when you enable the DMA, the transfer starts.
  3. Finally, enable DMA and fire it.
  • \$\begingroup\$ Um, you want use DMA to transfer data from SRAM to LCD, right? \$\endgroup\$
    – diverger
    Nov 17, 2014 at 8:36
  • \$\begingroup\$ yes..correct!!! \$\endgroup\$
    – spp
    Nov 17, 2014 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.