2022-05-09 11:25 PM
I have created a pointer to function like void (*MyFun)(void); and I assigned first time 0x00000000 and the second time 0x08000000. in both cases after call MyFun(); I get HardFault error.
Why?
PS. This is simple project created in CubeIDE (default project for STM32F103) and I only add some lines of code to call MyFun();
2022-05-10 12:14 AM
it represents the start of rom at two addresses. At the start of the rom, there is a vector table in the file called startup_stm32xxxxx.s, where you can see the contents. there is no executable code
2022-05-10 01:04 AM
Besides the above, the function address for any Cortex-M must be an odd number (real function address with bit 0 set to 1). Generally: do not hardcode any function addresses; use proper type cast when you have to.
2022-05-10 03:02 AM
I tried to call this MyFun with address 0x00000001, 0x00000004, 0x08000001, and 0x08000004 and still the same -> HardFault
2022-05-10 03:14 AM
Is there actually CODE there, or ADDRESSES in a vector table?
The.processor can't execute addresses!
For those you'll need to do a 32-bit read and transfer control to that location, rather than the table.
2022-05-10 03:41 AM
0x08000000 has stack end address in it
0x08000004 contains the address of the code to be processed after reset
0x08000008 contains the address of the NMI_Handler function
0x0800000c has the address of HardFault_Handler in it
...
the vector table continues to settle in this way.
These are defined in a file like startup_stm32h753xx.s
In order to work with these addresses, you need to define as pointer to pointer.
2022-05-10 05:19 AM
Yes, You're right. I didn't think of it that way. :(
2022-05-11 12:34 AM
Can you tell me how to create a pointer to pointer for fuction? Like in this example.
Address 0x08000004 holds address to code execute. How to use it?