Skip to main content
Visitor II
May 28, 2024
Solved

Address jump function

  • May 28, 2024
  • 1 reply
  • 1373 views

Hi,

 in my project I am try to jump 0x8002000 address . but I am facing some failure,

 

typedef void (*FunctionPointer)(void);
 
// Example function to jump to another address
void jumpToAddress(uint32_t * address) {
 
//address =0x800029c;
    // Define a function pointer with the address
    FunctionPointer jumpFunction = (FunctionPointer)address;
    //void (*jumpFunction)(void) = (void (*)(void))address;
 
    // Disable interrupts if needed
       __disable_irq();
 
       // Set the program counter (PC) to the new address
       SCB->VTOR = address;
 
       // Execute an instruction to ensure that the jump takes effect
       __DSB();
       __ISB();
 
       // Re-enable interrupts if needed
       __enable_irq();
 
    // Call the function via the function pointer
    jumpFunction();
}
 
 
this is my address jump function .
 

int main(void)
{
/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */
MX_GPIO_Init();
/* USER CODE BEGIN 2 */
//myFunction();
jumpToAddress(0x8002000);

/* USER CODE END 2 */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

this is my main function.

 

NandhakumarGanesan_0-1716892537128.png

this image is my .map file for my project.

I am try to jump 0x8002000 address my project  shown ,

 

NandhakumarGanesan_1-1716892659863.png

 

 

this output. so kindly help to me.

thanks

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

    Vector tables need to be on 512-byte boundaries.

    They are tables of addresses, not code.

    Thr function pointer needs to be odd, per how the CMx processor indicates 16-bit Thumb code.

    Have a working/reporting HardFault_Handler so you know it got there.

    Learn to use the debugger so you can step the code and understand behaviour and failure.

    1 reply

    Graduate II
    May 28, 2024

    Vector tables need to be on 512-byte boundaries.

    They are tables of addresses, not code.

    Thr function pointer needs to be odd, per how the CMx processor indicates 16-bit Thumb code.

    Have a working/reporting HardFault_Handler so you know it got there.

    Learn to use the debugger so you can step the code and understand behaviour and failure.

    Visitor II
    May 28, 2024

    thanks for your response.

    I am a beginner for ARM  Based controller. So kindly  explain for this address jumping process or kindly give sample code for this process or kindly share document for this process.

     

     

     

    Visitor II
    May 28, 2024

    hi,

     

    I am try below  mentioned method in way Hardfaulthandler error is happend.

    NandhakumarGanesan_0-1716897132891.png

    kindly help to me. I am struggling  past 4 days .