cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745 LTDC define 3 framebuffer in SDRAM

M_R
Associate

Hello,
I'm using STM32H745XIH(M7 side) & interfacing 1280X800 LCD-TFT with STemWin library.

In MPU_Config I've defined 2 region as NON_CACHE(8MB) and CACHE(8MB) in SDRAM(Starting address 0xC0000000).
Framebuffer define in NON_CACHE region & aGuiDataMemory define in CACHE region.

For 2 framebuffer(with ARGB8888) it works fine but some lag found in screen while transition.

So, define NUM_BUFFERS=3 in LCDConf.c, and extend the NON_CACHE region to 16MB & also define SDRAM LENGTH = 24M in linker script. Now my program crashes at run time when i try to access CACHE memory(memset aGuiDataMemory in GUI_X_Config function).
Debugging code gives Hardfault at this point.

When I change linker script CACHE start address from 0xC00000(for 2 buffer configuration) to 0x1000000(for 3 buffer configuration) program crashes as above mention.
In Build Analyzer,
2 framebuffer consumes 7.8125 MB
3 framebuffer consumes 11.71875 MB

In linker script:
MEMORY

SDRAM (xrw)      : ORIGIN = 0xC0000000, LENGTH = 24M 
}

 .sdram (NOLOAD):
  {
    _ssdram = .;

    /* 16MB NonCache */
    . = ALIGN(4);
    _ssdram_ncache = .;       /* create a global symbol at sdram start */
    *(.sdram_ncache)
    . = ALIGN(4);
    _esdram_ncache = .;       /* create a global symbol at sdram end */
        
    /* 8MB Cache */    
    . = ALIGN(4);
/*    . = 0xC00000;   Keep offset of around 4MB as per https://www.keil.com/support/docs/3777.htm */
    _ssdram_cache = .;       /* create a global symbol at sdram_gui start */
    *(.sdram_cache)
    . = ALIGN(4);
    _esdram_cache = .;       /* create a global symbol at sdram_gui end */

    _esdram = .;
  } >SDRAM


In MPU_Config:

void MPU_Config(void)
{
  MPU_Region_InitTypeDef MPU_InitStruct = {0};

  /* Disables the MPU */
  HAL_MPU_Disable();

/* DEFINE NON CACHE AREA */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.BaseAddress = 0xC0000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_16MB; 
MPU_InitStruct.SubRegionDisable = 0x0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

  /** Initializes and configures the Region and the memory to be protected
   *  Define CACHE AREA
  */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER2;
  MPU_InitStruct.BaseAddress = 0xC1000000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;
  MPU_InitStruct.SubRegionDisable = 0x0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;

  HAL_MPU_ConfigRegion(&MPU_InitStruct);

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

What I am missing here?

1 REPLY 1
M_R
Associate

Configuring Region as per MPU configuration example(Section 6.2.7) in AN4861 gives faster transition between screens, but still some glitches found in Screen transition.

 

Can anyone guide me on this..