AnsweredAssumed Answered

DMA between external SRAM and LCD on FSMC

Question asked by Kilohercas on Oct 16, 2012
Latest reply on Oct 17, 2012 by jj.sprague
hello,
i am trying to learn how to use DMA for frame buffer.
Idea is to manualy fill SRAM with data (10k points each 16b) and send to LCD by using DMA.
FSMC_Bank1_NORSRAM2 and adress:
#define Bank1_SRAM2_ADDR  ((uint32_t)0x64000000)
LCD is on
#define LCD_REG       (*((volatile unsigned short *) 0x60000000)) // RS = 0
#define LCD_RAM       (*((volatile unsigned short *) 0x60020000)) // RS = 1
is this DMA Config is right ?
NVIC_InitTypeDef NVIC_InitStructure;
 DMA_InitTypeDef  DMA_InitStructure;
    
 /* Enable DMA clock */
 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
  
 /* Reset DMA Stream registers (for debug purpose) */
 DMA_DeInit(DMA_STREAM);
 while (DMA_GetCmdStatus(DMA_STREAM) != DISABLE)
 {
 }
  
 DMA_InitStructure.DMA_Channel = DMA_Channel_0; 
 DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) 0x64000000;
 DMA_InitStructure.DMA_Memory0BaseAddr = ((uint32_t)(0x60000000 | 0x60020000));
 DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToMemory;
 DMA_InitStructure.DMA_BufferSize = (uint32_t) 10000;
 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_Circular;
 DMA_InitStructure.DMA_Priority = DMA_Priority_Low;
 DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;        
 DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
 DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
 DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
 DMA_Init(DMA_STREAM, &DMA_InitStructure);
    
 /* Enable DMA Stream Transfer Complete interrupt */
 DMA_ITConfig(DMA_STREAM, DMA_IT_TC, ENABLE);
 
 /* DMA Stream enable */
 DMA_Cmd(DMA_STREAM, ENABLE);
 
 NVIC_InitStructure.NVIC_IRQChannel = DMA_STREAM_IRQ;
 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 NVIC_Init(&NVIC_InitStructure);

Before i start 10k points transfer, i need prepare LCD, does any one know how DMA Transfer start interrupt is called ? since now i just have DMA Stream Transfer Complete interrupt

Code is half working, i get some right data on screen, but with lot of errors

Outcomes