cancel
Showing results for 
Search instead for 
Did you mean: 

10FPS using the FSMC

Ahmed Tolba
Associate II
Posted on June 18, 2014 at 22:38

I have a C Function which tries to copy a framebuffer to FSMC RAM, which is connected to LCD. The functions eats the frame rate of the game loop to 10FPS. It seems copying from the SDRAM to FSMC is terribly slow, but why ?

void

LCD_Flip()

{
u16 i,limit = fbHeight+fbWidth;
// We will use a precalculated limit and one single loop
LCD_SetCursor(0x00, 0x0000);
LCD_WriteRegister(0x0050,0x00);
//GRAM horizontal start position
LCD_WriteRegister(0x0051,239);
//GRAM horizontal end position
LCD_WriteRegister(0x0052,0);
//Vertical GRAM Start position
LCD_WriteRegister(0x0053,319);
//Vertical GRAM end position
LCD_WriteIndex(0x0022);
// Single loop from 0:limit-1 takes care of having to do an
// x,y conversion each iteration.
for
(i=0;i<limit;j++)
{
u16 color = frameBuffer[i];
LCD_WriteData(color);
}
}

4 REPLIES 4
Posted on June 18, 2014 at 23:38

The loop isn't good, the optimizer might help, subroutine call makes it less efficient.

If the write function isn't inlined, that's throwing away thousands of cycles.

What's going on in the subroutine?

The FSMC might be set up for slower external writes.

Can the write be done more efficiently as a burst?

Can you unroll the loop?. Or use LDM/STM in assembler?

Can you use DMA2?

Can you use an STM32F429 and drive a dumb panel instead of a controller based one?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Ahmed Tolba
Associate II
Posted on June 24, 2014 at 15:04

Thanks for your fast reply!.

The subroutine, only writes to the FSMC memory

I even replaced the subroutine to the the following line, and it's still very slow writing and very slow FPS~

*(__IO uint16_t *) (Bank1_LCD_D) = frameBuffer[i];

The problem with a newer controller, is I need to buy a new kit, I'm just doing that for hobby and I can't afford the F4 :(. How would I optimize the writing to the FSMC ? First I will try to unroll the loop then I will use DMA. is there any other solution without resorting to DMA,..etc? I'm really wondering, what's wrong with copying an array to the FSMC like I'm doing.
Posted on June 24, 2014 at 16:32

You'd want to look at your compiler settings, and the code it generates.

You'd want to look at the FSMC configuration.

Copying large arrays to external buses is significantly slower than accessing internal memories.

Consider using pointers?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stm32forum
Associate II
Posted on June 24, 2014 at 16:57

Your using i but increase j

// Single loop from 0:limit-1 takes care of having to do an
// x,y conversion each iteration.
for
(i=0;i<limit;j++)