cancel
Showing results for 
Search instead for 
Did you mean: 

How to use DTCM RAM?

carloV
Associate III

I'd like to use the DTCM ram in my code; how can I do ?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

Describe the memory regions in your linker script or scatter file.

Use compiler directives say attributes or pragmas to direct specific code, or buffers to use the memory.

Code in specific source files, via object file, can be directed via linker scripts

A for filling/preloading DTCM, for GNU/GCC you'd need to add initialization code in startup.s and staging via the linker script, in a similar manner to how statics are handled for RAM from FLASH

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

View solution in original post

6 REPLIES 6
TDK
Super User

Solved: Using ITCM and DTCM memories - STMicroelectronics Community

If you feel a post has answered your question, please click "Accept as Solution".
carloV
Associate III

Thank you,

I know that is very important to understand the MPU architecture, but what I need to know is:

in what way can I insert in my project some lines of code that  make that type of memory (DTCM, ITCM,...) usage available  to my project.

 

 

You would do this in the Linker script (the .ld file, for CubeIDE) rather than in the code.

The thread @TDK linked says, "See also X-CUBE-PERF-H7 (related to the said application note) how linker files are implemented" ...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Describe the memory regions in your linker script or scatter file.

Use compiler directives say attributes or pragmas to direct specific code, or buffers to use the memory.

Code in specific source files, via object file, can be directed via linker scripts

A for filling/preloading DTCM, for GNU/GCC you'd need to add initialization code in startup.s and staging via the linker script, in a similar manner to how statics are handled for RAM from FLASH

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

I will be looking into Andrew's suggestion as well. But, in the mean time if you just want to see how you can improve the speed of a routine you can use the attribute prior to the routine:

/*
 * @brief ADE9430 Initialization.
 * @PAram  hspi   : pointer to a SPI_HandleTypeDef structure that contains
 *                  the configuration information for SPI module.
 * @return 0 (HAL_OK) in case of success, error code otherwise.
 */
__attribute__((section(".ITCM_Section")))
int ade9430_init(SPI_HandleTypeDef *hspi_pq, SPI_HandleTypeDef *hspi_s2, SPI_HandleTypeDef *hspi_s1)
{

 

and, of course your linker script would have to refer to the ITCM memory as .ITCM_Section

  .ARM.attributes 0 : { *(.ARM.attributes) }

 /*  Unitialized ITCM section into "ITCM" ITCM type memory [MMT section] */
 .ITCM_Section :
  {
    . = ALIGN(4);
    KEEP (*(.ITCM_Section))
    . = ALIGN(4);
  } >ITCM
  
.dtcm_data :
{
    . = ALIGN(4);
    *(.dtcm_data)     /* Include data */
    . = ALIGN(4);
} AT> DTCM
 

when I did this and looking at the routine on a logic analyzer, before and after using ITCM I

saw a vast improvement.

Still struggling with DTCM but still plan to use it. I'm not able to get more than 64K specified and I

used the following to put data in the DTCM area:

volatile uint8_t __attribute__((section (".dtcm_data"))) __attribute__((aligned(32))) gShadowPQ_WFB[SIZE_ADE9430_uC_WFB] = {1, 2, 3, 4, 5, 6, 7, 8};

GREAT !

I've used the "attribute section" and it works good:

 

float32_t accL[6000] __attribute__((section("DTCMRAM")));

float32_t accR[6000] __attribute__((section("DTCMRAM")));

float32_t float_buffer_L[6000] __attribute__((section("DTCMRAM")));

float32_t float_buffer_R[6000] __attribute__((section("DTCMRAM")));

 

the four buffers seem to be placed in the DTCMRAM area:

 

arm-none-eabi-size MedAudioDev.elf

text data bss dec hex filename

211572 96220 181092 488884 775b4 MedAudioDev.elf

Finished building: default.size.stdout

 

even if it doesn't appear in the Build Analyzer...

 

carloV_0-1748503253258.png

 

Thank you