This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Start bootloader with an Interrupt call (_trap_)

I wanted to programm a bootloader for in-application programming. If an application was programmed with the bootloader, the bootloader starts the application.

If i want to programm a new application, the old application tranfers control to the bootloader with an interrupt call (_trap_0x7F).

What must i attend when i jump tho the bootloader with a software interrupt? The interrupt function calls not the main() function but an other function in my bootloader programm.

Parents
  • At the start of your bootloader have some code that says if R1 == some prescribed value, and the last reset was a software reset (check the SYSSTAT register), then set R1 = 0 and vector off to your application code.

    So:

    * At initial power on, SYSSTAT will indicate a hardware reset. The bootloader is then able to check if an application is available.
    * It it is, it sets R1 to the aforementioned prescribed value, and throws a software reset. This should get the application going.
    * When in the application, to get back to the bootloader, you just have to reset with R1 set to something other than your chosen value.

    I chose R1 for this because (for my setup at least) it isn't cleared by reset. But any location in RAM that isn't cleared by reset will do.

Reply
  • At the start of your bootloader have some code that says if R1 == some prescribed value, and the last reset was a software reset (check the SYSSTAT register), then set R1 = 0 and vector off to your application code.

    So:

    * At initial power on, SYSSTAT will indicate a hardware reset. The bootloader is then able to check if an application is available.
    * It it is, it sets R1 to the aforementioned prescribed value, and throws a software reset. This should get the application going.
    * When in the application, to get back to the bootloader, you just have to reset with R1 set to something other than your chosen value.

    I chose R1 for this because (for my setup at least) it isn't cleared by reset. But any location in RAM that isn't cleared by reset will do.

Children
No data