Menu

Interrupt vector patch

Help
2015-07-13
2015-07-16
  • Peter Stone

    Peter Stone - 2015-07-13

    I have a need to redirect the standard interrupt vector at location 0x0008 to another memory location (0x1008) where a separately compiled interrupt routine lives.
    I have tried to use an inline assembly patch
    asm org 0x0008
    goto 0x1008
    This results in the GCB assembler complaining about location 0x0008 being redefined.
    I do not want to hand patch the assembly file each time and assemble separately.

    Is there another way to achieve this goal?

    Peter.

     
  • Anobium

    Anobium - 2015-07-13

    Which chipset?

     
  • Peter Stone

    Peter Stone - 2015-07-13

    Sorry. PIC18F26k22.

     
  • Anobium

    Anobium - 2015-07-14

    I had a workaround for the 16f.

    @Hugh... Help us Obe-One.

     
  • Peter Stone

    Peter Stone - 2015-07-15

    Hugh, Any brilliant revelations?

     
  • Hugh Considine

    Hugh Considine - 2015-07-15

    Some code like this should work in the bootloader:

    Sub Interrupt
        goto 0x1008
    End Sub
    

    Any code placed in a subroutine called Interrupt will be placed at the interrupt vector, or at least jumped to directly from it. GCBASIC will add any On Interrupt handlers to the start of the sub, and will also add context saving and restoring code. The context saving and restoring would be a problem with what you're aiming for, because both the bootloader and the application code would save and restore. That would end up corrupting W, STATUS, and maybe other stuff.

    To avoid that, I've added a new option to the compiler:

    #option NoContextSave
    

    This will prevent any context save/restore code being added. With the new build of the compiler, you can add that to the bootloader code and it will prevent anything being done except for jumping straight to the application code. Note that this means you need to be very careful in the bootloader interrupt routine - don't copy any values anywhere because that will probably corrupt the W register.

    Peter, you should have an email with the updated compiler. Others, I've also checked the source into SVN, and will put a new exe out soon. The new compiler will also require tweaked chip data files to work properly with some AVR chips, these are coming but aren't quite ready yet. It will be in the next Hot Release.

     
  • Peter Stone

    Peter Stone - 2015-07-16

    After my first quick compile of my test code, I get an error SYSINTOFFCOUNT not defined.
    Early in my code I disable interrupts (a force of habit just to be sure they are off). I think this might result in the requirement to use SYSINTOFFCOUNT which I can only assume has been deleted by the new option switch.

    Peter.

     
  • Anobium

    Anobium - 2015-07-16

    Post code, dat file as a zip. Please.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.