Skip to main content
NNar
Associate II
August 9, 2019
Solved

Calling a function by it's address not working

  • August 9, 2019
  • 2 replies
  • 889 views

Using a STM32F0 discovery board, I have this function:

void BlinkBlue(void)
{
	for (int i=0; i<20; i++)
	{
 		HAL_GPIO_WritePin(LD4_GPIO_Port, LD4_Pin, GPIO_PIN_SET);
 		HAL_Delay(50);
 		HAL_GPIO_WritePin(LD4_GPIO_Port, LD4_Pin, GPIO_PIN_RESET);
 		HAL_Delay(50);
	}
}
 

and I can call it in code by using:

BlinkBlue();

All good.

The .map file says it's location at address 0x8000a9c . But it doesn't work if I instead call it using:

((void (*)(void))0x8000A9C)();

Any idea why this wouldn't work? Thanks.

This topic has been closed for replies.
Best answer by Tesla DeLorean

>>Any idea why this wouldn't work?

Thumb code uses an ODD address, ie 0x08000A9D

Perhaps try printf("%p\n",&BlinkBlue);

2 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
August 9, 2019

>>Any idea why this wouldn't work?

Thumb code uses an ODD address, ie 0x08000A9D

Perhaps try printf("%p\n",&BlinkBlue);

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
NNar
NNarAuthor
Associate II
August 10, 2019

This solved it. Thanks!