cancel
Showing results for 
Search instead for 
Did you mean: 

Relocating frame buffer to internal SRAM

Andrew Stevenson
Associate II
Posted on August 07, 2017 at 11:54

Hello everyone,

I am attempting to relocate the frame buffer of the 'STemWin_HelloWorld' supplied with the STM32F429 Discovery kit. I would like to use the internal SRAM instead of the external SDRAM. Our project only requires 240x320 8 BPP so the SDRAM is not required.  

Has anyone any experience with how to do this?

My steps so far are based on the demo code at C:\STM32Cube_FW_F4_V1.16.0\Projects\STM32F429I-Discovery\Applications\STemWin\STemWin_HelloWorld. I am running the example code on the actual Discovery kit.

I changed the &sharpdefine LCD_LAYER0_FRAME_BUFFER in LCDConf_stm32f429i_disco_MB1075.c to the address of the 112KB SRAM which is 0x2000 0000 (page 85 of en.DM00071990.pdf).

When I run the code on the debugger the program stops in the HardFault_Handler() and the call stack is indicating it failed after CUSTOM_FillRect() calls DMA2D_FillBuffer().

Any suggestions gratefully received.

Regards,

Andrew.

#sram #ltdc #stm32f429-disco #stm32f429 #sdram
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on August 10, 2017 at 05:35

During compilation, variables are located in the SRAM area and you can not predict where the are located.

Best practise would be to allocate the frame buffer as a array, too.

uint8_t myframebuffer[320*240];

Then create a pointer

uint8_t *ptr_myframebuffer = &myframebuffer[0];

After initialisation of the LTDC with the default memory location, set the framebuffer to the array.

HAL_LTDC_SetAddress(&hltdc, (uint8_t)ptr_myframebuffer, 0);

Adjust the variable names to your needs.

You can monitor the framebuffer location with STMStudio. The value might cange with every compilation of your project.

Best regards,

Markus.

View solution in original post

3 REPLIES 3
Posted on August 10, 2017 at 05:35

During compilation, variables are located in the SRAM area and you can not predict where the are located.

Best practise would be to allocate the frame buffer as a array, too.

uint8_t myframebuffer[320*240];

Then create a pointer

uint8_t *ptr_myframebuffer = &myframebuffer[0];

After initialisation of the LTDC with the default memory location, set the framebuffer to the array.

HAL_LTDC_SetAddress(&hltdc, (uint8_t)ptr_myframebuffer, 0);

Adjust the variable names to your needs.

You can monitor the framebuffer location with STMStudio. The value might cange with every compilation of your project.

Best regards,

Markus.

Andrew Stevenson
Associate II
Posted on August 16, 2017 at 11:25

Markus,

Thank you for your reply, I have it working now. I also had to change the colour depth to L8 to avoid a hard fault when the display was turned on.

Best regards,

Andrew.

mstfa.okcu1
Associate

Andrew Stevenson,

How did you make changes to the LCDConf_stm32f429i_disco_MB1075 file? I tried the same method, but I had problems. I've changed the LCD_LAYER0_FRAME_BUFFER to 0x20000000. Can you please help me?