The STM32F407 is equipped with a 64kB of Core Coupled Memory (CCM) allowing 0-wait state execution. The CCM is usually used to store critical data. However, it can be used to store code instead of data. To use it we need to define this memory region inside the linker script as discussed in this post. But for storing code in CCM rather than data the ccm
region should be modified as below:
.ccm :
{
. = ALIGN(8);
*(.ccm .ccm*)
} > CCM
To relocate a specific function inside the CCM we can use the GCC keyword __attribute__
.
For example:
void __attribute__((section(".ccm"))) function_name()
{
...
}