Placement of functions in CCMRAM
Hello, i work with STM32F407ZG MCU, i need to place functions in RAM and CCMRAM sections. Placement of functions in RAM is correct, but they take longer than in flash. If I place functions in CCMRAM, then when I call the function, I get an error Hard Fault. I don't understand why functions take longer to execute in RAM than in flash, How to get rid of the error Hard Fault.
I Use STM32CubeIDE.
In ld-script:
/*--- New CCMRAM linker section definition ---*/
_siccmram = LOADADDR(.ccmram);
/* CCMRAM section */
.ccmram :
{
. = ALIGN(4);
_sccmram = .; /* define a global symbols at ccmram start */
*(.ccmram)
*(.ccmram*)
. = ALIGN(4);
_eccmram = .; /* define a global symbols at ccmram end */
} >CCMRAM AT> FLASH
/*--- End of CCMRAM linker section definition ---*/Test func
__attribute__((section (".ccmram")))
void testFunc()
{
int i;
for (i = 0; i < 0xFF * 10; i++)
{
static int a = 0;
a++;
}
}A function that copies data from flash to ram (i call it in main)
void CopyFlashToRamFunc(void) {
extern const unsigned char _siccmram;
extern unsigned char _sccmram;
extern unsigned char _eccmram;
uint32_t *pSrc, *pDest;
pSrc = & _siccmram;
pDest = &_sccmram;
if (pSrc != pDest) {
while(pDest < &_eccmram)
{
*pDest++ = *pSrc++;
}
}
}