Skip to main content
Visitor II
February 26, 2016
Question

Problems with jp instruction

  • February 26, 2016
  • 2 replies
  • 695 views
Posted on February 26, 2016 at 10:04

We are using assembler code in our C-code. The jp instruction is used to jump into

the booloader. But sporadic the jp instruction is not working. We have also used jpf instruction. Without success. What can be the reason?

if ( RequestJumpToBoot )

    {

        u8 option_byte = 0;

        uart1SendTxData (''-> jump to BOOTLOADER'' );

    

        // set option bit for bootload mode

        eepromReadAccess(EEPROM_BOOTLOADER_OPTION,1,&option_byte);

        option_byte |= BOOTLOAD_MODE;

        eepromWriteAccess(EEPROM_BOOTLOADER_OPTION,1,&option_byte);

                

                // disable all timers

                TIM1_DeInit();

                TIM2_DeInit();

                TIM4_DeInit();

    

        _asm(''jp 0x8000\n'');        // jump to bootloader

  }
    This topic has been closed for replies.

    2 replies

    Visitor II
    February 26, 2016
    Posted on February 26, 2016 at 11:12

    Hello,

    I would say that in the cases where the jp ''does not work'' the actual code execution does not get there, so the problem is not with the jump itself but is before it (maybe some interrupt coming and never returning, or stuck in the eeprom routines..)

    not very helpful I'm afraid, but I don't think the problem is in the jump.

    Visitor II
    March 1, 2016
    Posted on March 01, 2016 at 17:25

    Hi there

    Looks like you're trying to reset the processor by jumping directly the the reset vector. This could cause problems depending on any interrupts you still have enabled, and won't re-initialise the hardware. In my application I achieve a similar effect by executing an illegal opcode, which is guaranteed to cause a true hardware reset. I don't recall where I found it documented, but I use

    _asm(''dc.b 0x75\n'')

     . Note that the optimiser sometimes removes this, so you may need to follow it by a

    nop()

     

    Hope this helps

    Best regards

    Jonathan