cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a function by it's address not working

NNar
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions

>>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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

>>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
Up vote any posts that you find helpful, it shows what's working..
NNar
Associate II

This solved it. Thanks!