cancel
Showing results for 
Search instead for 
Did you mean: 

DMA: SRAM to LCD (FSMC)

mikecgale
Associate II
Posted on June 22, 2010 at 16:21

DMA: SRAM to LCD (FSMC)

10 REPLIES 10
mikecgale
Associate II
Posted on May 17, 2011 at 13:55

Thanks for your help Chikos. I have changed it to a memory to memory copy, but with no effect. I have also added the following line to the end of the program:

while (DMA_GetCurrDataCounter(DMA1_Channel1) > 0);

The data seems to get flushed, but it seems to still be missing some configuration parameter or function call.

(1) Is my 

DMA_PeripheralBaseAddr

correct for the STM3210E-EVAL board?

(2) Do I need to clear any special flags using the

DMA_ClearFlag()

function?

Michael

chikos332
Associate II
Posted on May 17, 2011 at 13:55

0690X0000060MlDQAU.gif

A

Hi,

You have wrong DMA configuration:

DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;

//--> replace it with : DMA_InitStructure.DMA_M2M = DMA_M2M_Enable;

FSMC is considered as memory not peripheral.

Cheers.

mikecgale
Associate II
Posted on May 17, 2011 at 13:55

Yes, that example does indeed work; it is writing to an SRAM location and then reading what it read back into a buffer so that it can be verified. Is it possible to even write to LCD memory directly (or at least the bank of RAM used for the display)? Basically, I want to throw some color values into an array and write those values to the LCD screen via DMA. If it is possible, then what would be the address for that LCD screen so that I can set

DMA_MemoryBaseAddr

correctly?

Thanks,

Michael

chikos332
Associate II
Posted on May 17, 2011 at 13:55

Hi,

You can start checking that your HW is OK by loading the ST DMA-FSMC example (in folder: ''STM32F10x_StdPeriph_Lib\Project\STM32F10x_StdPeriph_Examples\DMA\FSMC'',

http://www.st.com/stonline/products/support/micro/files/stm32f10x_stdperiph_lib.zip

).

If this example works correctly on your HW, then try to replace your configuration by the example configuration (SRAM init, DMA channels, data format...)

Cheers.

chikos332
Associate II
Posted on May 17, 2011 at 13:55

Hi,

I had a look on ST LCD driver for STM3210E-EVAL evaluation board, and they are using address: FSMC_Bank1_NORSRAM4 ..

Try to use this driver if you have the same or similar LCD, it would be easier for you. (it is located in folder: ''STM32F10x_StdPeriph_Lib\Utilities\STM32_EVAL\STM3210E_EVAL\stm3210e_eval_lcd.c'')

mikecgale
Associate II
Posted on May 17, 2011 at 13:55

Thanks for the tip, chikos. I have, in fact, used the LCD routines provided but they don't provide the kind of performance I need. I believe I have tried that address already, but I will double check just to be sure. Here is whole main() function:

int main(void)

{

  int i = 0;

  /* System Clocks Configuration */

  RCC_Configuration();

  uint16_t data[480];

  for (i = 0; i < 480; i++) data[i] = LCD_COLOR_RED;

  DMA_InitTypeDef DMA_InitStructure;

  DMA_DeInit(DMA2_Channel5);

  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)data; // local array

  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)FSMC_Bank1_NORSRAM4; // FSMC

  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;

  DMA_InitStructure.DMA_BufferSize = 480;

  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_Enable;

  DMA_Init(DMA2_Channel5, &DMA_InitStructure);

  DMA_Cmd(DMA2_Channel5, ENABLE);

  while (!DMA_GetFlagStatus(DMA2_FLAG_TC5));

  DMA_ClearFlag(DMA2_FLAG_TC5);

  while (1);

}

Michael

jpeacock23
Associate III
Posted on May 17, 2011 at 13:55

jpeacock23
Associate III
Posted on May 17, 2011 at 13:55

One other point on your fill routine.  Since you are writing a constant, just set up one memory location instead of a 480 buffer, and then DMA from it without setting memory increment.

mikecgale
Associate II
Posted on May 17, 2011 at 13:55

That's a good tip, thanks! Has anyone managed to get DMA working in this fashion? The simplest test case I am trying to accomplish is to write (a single color value multiple time to the screen using DMA.) From what I understand, this means I must use the FSMC. What I am unsure about is how to address the area representing LCD memory managed by the FSMC?