CCM SRAM
コア結合メモリ(Core Coupled Memory)
CPUコアの内部に存在するコアに密接に接続されているメモリ ウェイト無しでの高速読み書きが可能
プログラムや変数をCCM SRAMに配置したい
GCCやCubeIDE
リンカスクリプトの編集
データシートなどを確認してCCM SRAMの開始アドレスとサイズを追加する
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 112K
CCMSRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 16K /* CCM SRAM */
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 254K
}
.data,.bssの間あたりに追加する
_siccmsram = LOADADDR(.ccmsram);
.ccmsram :
{
. = ALIGN(4);
_sccmsram = .; /* create a global symbol at ccmram start */
*(.ccmsram)
*(.ccmsram*)
. = ALIGN(4);
_eccmsram = .; /* create a global symbol at ccmram end */
} >CCMSRAM AT> FLASH
アセンブリコードの編集
b LoopCopyDataInit1 CopyDataInit1: ldr r3, =_siccmsram ldr r3, [r3, r1] str r3, [r0, r1] adds r1, r1, #4 LoopCopyDataInit1: ldr r0, =_sccmsram ldr r3, =_eccmsram adds r2, r0, r1 cmp r2, r3 bcc CopyDataInit1
コードで割当
__attribute__((section(".ccmsram"))) static volatile float phase_current_u[log_length]{0.0f};
IAR EWARM、Keil MDK-ARM、CubeIDEでSTM32F3 / G4 CCM SRAMからプログラムを実行する方法
AN4296 Use STM32F3/STM32G4 CCM SRAM with IAR Embedded Workbench®, Keil®
MDK-ARM, STMicroelectronics STM32CubeIDE and other GNU-based toolchains
Using CCM Memory
How to place and execute STM32 code in SRAM memory with STM32CubeIDE.