cancel
Showing results for 
Search instead for 
Did you mean: 

Code in CCM RAM

matic
Associate III
Posted on January 09, 2016 at 20:36

Hi.

I tried to put code in a CCM RAM (STM32F303) as described in AN4296 and I was very impressed. It was more than 30% faster, than if the code is in flash.

Mentioned PDF (AN4296) says that it is not recommended to place both code and data together in the CCM, because there would be a risk of ''collision''. Is that problem the same if I place in the CCM (beside code) a look-up table, which is a constant? Now I have it stored in a flash.

Thanks
14 REPLIES 14
Radosław
Senior II
Posted on January 10, 2016 at 12:58

The risk of corruption of program in CCRAM is only if stack is placed in CCRAM too ofcourse.

If you know how big stack your application needs  then any corruption is impossible.

Which IDE you are using?

matic
Associate III
Posted on January 10, 2016 at 13:56

Thanks.

I use uVision form Keil. Why?

Should there be any profit, if I place variables (not stack) in CCM RAM too, instead in regular SRAM? 

Radosław
Senior II
Posted on January 10, 2016 at 14:20

Not always. Code in CCRAM will be quicker of course. But when placing code in RAM must remember that this code can call some function from flash (standard function like memcpy). Putting a global data to CCRAM will have a minimal influence on speed. Data used very often for example like data for FFT can be placed in CCRAM for speed up calculations. Stack is more important, of course it's depend on programing style.

Did you use some standard libraries? SPL or HAL?

matic
Associate III
Posted on January 10, 2016 at 14:51

I started project with HAL/CubeMX, but then at some point reorganized all the files, so now I am independent of Cube. I use some HAL functions for initialization of peripherals, but in the main program I work directly with registers.

Radosław
Senior II
Posted on January 10, 2016 at 14:59

Mixing this programing styles it isn't good idea. But ok because using HAL (or SPL) libraries and talking about program speed i VERY BIG mistake.

matic
Associate III
Posted on January 10, 2016 at 20:43

I know that HAL functions are not meant for fast code execution. That's why I use them only for initializatinon (GPIO, ADC,...). But because of code readability I will probably do that directly with registers too.

I have one more question regarding CCM. Is speed increase when code is in CCM comparable with speed increase when ART Accelerator is used in more advanced series (F4 let say)? I know that F4 has higher operating frequency by default. But if you look F4 with or without ART Accelerator and F3 when code is in CCM or Flash. Are those two speed increases comparable?

Radosław
Senior II
Posted on January 10, 2016 at 21:28

Code from CCRAM should be quicker.

But answer for your question is not simply. You can do test, use coremark code for measurement.

But why you bother at this?
mikael239955_stm1_st
Associate III
Posted on January 10, 2016 at 21:36

How did your CCMRAM setup look like?

Posted on January 11, 2016 at 01:43

ART should be able to out-run SRAM/CCMRAM in most situations, those are 1-cycle memories, and the ART can service the prefetch in the same cycle, effectively providing 0-cycle access. The FLASH is also very wide, 128-bit (16-byte) so even on a miss, the subsequent reads will average out the upfront cost.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..