cancel
Showing results for 
Search instead for 
Did you mean: 

Why I can not call function from address 0x00000000 or 0x08000000?

sholojda
Associate III

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();

7 REPLIES 7
Muhammed Güler
Senior III

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

gbm
Lead III

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.

sholojda
Associate III

I tried to call this MyFun with address 0x00000001, 0x00000004, 0x08000001, and 0x08000004 and still the same -> HardFault

Is there actually CODE​ there, or ADDRESSES in a vector table?

The.processor can't execute​ addresses!

F​or those you'll need to do a 32-bit read and transfer control to that location, rather than the table.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Muhammed Güler
Senior III

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.

sholojda
Associate III

Yes, You're right. I didn't think of it that way. :(

sholojda
Associate III

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?