Hi,
I try to call a function by function pointer with absolute address, but not working. I am using Keil MDK v5.21, the function will be placed in particular memory by using the scatter file and compiler keyword such as __attribute__((section("name"))).
For Example, the function OrangeLed(void); will be placed in 0x08000400 and rest of the code will placed from 0x08000000 to 0x08000100. Now i am calling the OrangeLed() from main as shown below,
Trial1
typedef void (*pFunction1)(void); pFunction1 Jump_To_Led; uint32_t JumpAddress; void main(){ JumpAddress = *(volatile uint32_t*)0x08000400;/*Absolute address of OrangeLed()*/ Jump_To_Led= (pFunction1) JumpAddress; Jump_To_Led();/*calling the OrangeLed()*/ while(1){ blinkRedLed(); } }
Trial2 by referring http://www.keil.com/support/docs/3240.htm
typedef void (*pFunction1)(void); typedef void (*pFunType)(void); void main(){ pFunType pFunction1 = (pFunType)0x08000400;/*Absolute address of OrangeLed()*/ (*pFunction1)();/*calling the OrangeLed()*/ while(1){ blinkRedLed(); } }
Other detail: C Compiler: Armcc.exe V5.06 Linker/Locator: ArmLink.exe V5.06 Target: STM32F072RB
In, both of the trials, it's not working. Can anybody help how to do this.
Vairamani.