Executing code from RAM problems
I'm developing application on stm32H7 and a need to execute small function from RAM. I add RamFunc derective, and describe in linker *(.RamFunc) in .data section. As a result, i certainly see, that function code moved to RAM address space. I compare byte to byte content of FLASH address with no RamFunc derective and RAM code with RamFunc. As A result it's clear that startup function move my code from FLASH to RAM.
Than i try just to execute my function from main just calling "fucntionName();", but then i get an interrupt
/**
* @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving
* the system state for examination by a debugger.
* @param None
* @retval None
*/
.section .text.Default_Handler,"ax",%progbits
Default_Handler:
Infinite_Loop:
b Infinite_Loop
I try to disable interrupts just before calling my RAM function and it's have no result. Also this problem ocurs if i stop before my RAM function and then from debugger step into. Next moment i get error and can not see what is in the PC register.
In my function i just init volatile variable and do some arithmetic above it.
I think, that i get problem with alignment. I'm not sure, how start address must be alignment, but location in FLASH is also not alignment to 32, 16, 8, 4.
Another moment that possible i need another way to call my function. Maybe not just writing myFunc(); from main, and do some additional movements with PC and SP registers.
I will be thankful for any ideas.