AnsweredAssumed Answered

DMA Configuration...

Question asked by russo.christian on Nov 22, 2012
Latest reply on Nov 22, 2012 by russo.christian
Hi, I'm developing on STM3240G-Eval board and I'm trying to use DMA for displaying an image from the SRAM memory on the LCD.

This is the code that I wrote:
void DMA_Write()
{
  uint32_t skippedCycles = 0;
  DMA_InitTypeDef DMA_InitStructure;

  /* 1. Enable DMA Controllers */
  RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_DMA1, ENABLE);
  
  /* 2. Enable and configure Peripheral DMA_Stream (not required by SRAM).*/
  LCD_WriteReg(LCD_REG_3, 0x1008);
  LCD_WriteRAM_Prepare();
 
  /* 3. DMA_Init().*/
  DMA_DeInit(DMA1_Stream0);
  while(DMA_GetCmdStatus(DMA1_Stream0) != DISABLE);
   
  DMA_InitStructure.DMA_Channel = DMA_Channel_0;
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) (0x64000000); // SRAM memory address
  DMA_InitStructure.DMA_Memory0BaseAddr = ((uint32_t)(0x60000000 | 0x60020000)); // LCD memory address
  DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToMemory;
  DMA_InitStructure.DMA_BufferSize = (uint32_t) (76800);
  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_Mode_Circular;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
  DMA_InitStructure.DMA_MemoryBurst = DMA_PeripheralBurst_Single;

  DMA_Init(DMA1_Stream0, &DMA_InitStructure);

  /* I'm not going to use DMA interrupts so I've commented this line... */
  // DMA_ITConfig(DMA1_Stream0, DMA_IT_TC, ENABLE);

   /* 6. Enable the DMA stream using the DMA_Cmd() function. */
  DMA_Cmd(DMA1_Stream0, ENABLE);

  while(DMA_GetCmdStatus(DMA1_Stream0) == DISABLE) {
    // Wait DMA Start...
    skippedCycles++;
  }
   
  skippedCycles = 0;
  while( DMA_GetFlagStatus(DMA1_Stream0, DMA_FLAG_TCIF0) == RESET) {
 
   // waiting DMA  completes transfer...
    DMA_ClearFlag(DMA1_Stream0, DMA_FLAG_TCIF0);
    skippedCycles++;
  }
 
  return;
}

At the moment the code compiles but seems that DMA1_Stream0 doesn't become ENABLE after the line DMA_Cmd(DAM1_Stream0, ENABLE) is called.
Did I make some mistakes? 

 

 

Outcomes