AnsweredAssumed Answered

LCD Scroll Slow with SDRAM as System Ram

Question asked by bandera.ruggero on Jul 20, 2016
I'using
       
  • STM32746G-Discovery board
  •    
  • keil 5.20
  •    
  • STM32F7xx_DFP/2.7.0

I do some test with LwIP_HTTP_Server_Netconn_RTOS examples.
This example use:
-    LwIp Library
-    LCD interface with the framebuffer mappend on the SDRAM 0xC0000000
All works fine I can do my Log on the LCD and the scroll is fast.

For my project I need to use the SDRAM 0xC0000000 as system ram.
So I look at the FMC_SDRAM_DataMemory example.

I did necessary modification into the LwIP_HTTP_Server_Netconn_RTOS example.
I fix the LwIP RX/Tx buffer address.
Note: I need to change also the MPU_Config to make the LwIp working. (to avoid memory exception)

Below the new MPU_Config() function:

//#define USE_INTERNAL_RAM (disco config)
static void MPU_Config(void)
{
  MPU_Region_InitTypeDef MPU_InitStruct;
 
  /* Disable the MPU */
  HAL_MPU_Disable();

  /* Configure the MPU attributes as WT for SRAM */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
#ifdef USE_INTERNAL_RAM
  MPU_InitStruct.BaseAddress = 0x20010000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_256KB;
#else
    MPU_InitStruct.BaseAddress = 0xC0000000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_8MB
#endif
    
    
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
#ifdef USE_INTERNAL_RAM
  MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
#else    
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
#endif

    MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER0;
    
#ifdef USE_INTERNAL_RAM
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;                                        

//Strongly ordered
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
#else
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;                                        //Shared

device
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
#endif
  MPU_InitStruct.SubRegionDisable = 0x00;

  HAL_MPU_ConfigRegion(&MPU_InitStruct);

  /* Enable the MPU */
  HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
    
}

After this modification all works fine but the LCD scroll is very slow.
I have a thread that blink a led each 250ms and when the system scrolls the led remain fixed about 1 second

I make some test an look into the code and the part of the code that slower the scroll is:

Into lcd_log.c:

LCD_LOG_PUTCHAR
{
    ...
#ifdef SKIP_THIS    
      for(idx = LCD_CacheBuffer_xptr ; idx < XptrNUM; idx++)
      {
        LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = ' ';
      }   
#endif
    ...
}

and

void LCD_LOG_UpdateDisplay (void)
{
    ...

    for  (cnt = 0 ; cnt < YWINDOW_SIZE ; cnt ++)
    {
      
      index = (cnt + ptr )% LCD_CACHE_DEPTH ;
      
      BSP_LCD_SetTextColor(LCD_CacheBuffer[index].color);
      BSP_LCD_DisplayStringAtLine ((cnt + YWINDOW_MIN),
                             (uint8_t *)(LCD_CacheBuffer[index].line));
      
    }

    ...

}

If I enable the define SKIP_THIS the scroll time is twice faster but always slow
respect the LwIP_HTTP_Server_Netconn_RTOS
without modifications.




 

Outcomes