• AVR Freaks

Hot!IVT in BootLoader and Application dspic33EPMU806

Author
Dareon
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2011/07/28 13:53:58
  • Location: 0
  • Status: offline
2020/02/18 12:15:38 (permalink)
0

IVT in BootLoader and Application dspic33EPMU806

I need to run some interrupts in both the bootloader and the application.
 
In the bootloader I define every interrupt with the following format.
 
void __attribute__ ((__interrupt__, __no_auto_psv__)) _OscillatorFail(void)
{
    if( interruptFlag == BOOTLOADER)
    {
        defaultInterrupt();
    }
    else
    {    
        asm("goto %0" : : "r"(APPLICATION_IVT + 0x00));//0x00 increases by 4 per each interrupt
    }
}
 
Then in the application I have a Jump IVT defined in the linker at address APPLICATION_IVT.  This is then filled in via the following.
 
    SHORT(DEFINED(__OscillatorFail_1) ? ABSOLUTE(__OscillatorFail_1) :
                ABSOLUTE(__DefaultInterrupt));
    SHORT(0x04);
    SHORT(((DEFINED(__OscillatorFail_1) ? ABSOLUTE(__OscillatorFail_1) :
                ABSOLUTE(__DefaultInterrupt)) >> 16) & 0x7F);
    SHORT(0);
 
These exist for every interrupt on my processor.  The interrupts work as expected in the bootloader.  Prior to going to the main application the bootloader disables all individual interrupts and also the global.  After the main application is started from the bootloader, the application updates the  interruptFlag and then enables the interrupts as necessary. Once an interrupt occurs it immediately software resets. 
 
As far as I can tell all the address for these ivt's and jivt's are correct.
 
Does anyone have any ideas of things to check/change?
#1

3 Replies Related Threads

    NorthGuy
    Super Member
    • Total Posts : 5965
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: IVT in BootLoader and Application dspic33EPMU806 2020/02/18 13:42:16 (permalink)
    0
    Your interrupt code will have some prologue, possibly saves something on the stack, this needs to be removed before you jump to the interrupt. Also, if need to make sure none of the registers is used while checking the flag. I don't know if you can ensure this in C.
     
    Then you code jump to the location in the application IVT as if your app's IVT contained code, while your app's IVT contains addresses.
     
    First you need to re-organize your IVT so that it contains jump instructions, not the addresses.
     
    Then, you need to re-write your ISRs in assembler to make sure that there's no prologue and that you preserve all the registers before it jumps to the desired address in the IVT. It might be possible to do this in C, but I'm not sure.
     
    You need to do the same for the bootloader interrupts.
    #2
    Dareon
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2011/07/28 13:53:58
    • Location: 0
    • Status: offline
    Re: IVT in BootLoader and Application dspic33EPMU806 2020/02/18 14:59:12 (permalink)
    0
    The only defined interrupt is in the bootloader where it is checking the flag, then running either its flag or running the   asm("goto %0" : : "r"(APPLICATION_IVT + 0x00)); command.
     
    It is not feasible to rewrite my interrupt functions in assembly, as one of them is the microchip usb stack.
    #3
    Dareon
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2011/07/28 13:53:58
    • Location: 0
    • Status: offline
    Re: IVT in BootLoader and Application dspic33EPMU806 2020/02/19 06:18:04 (permalink)
    0
    I am a C code guy so rewritting things in assembly is daunting.  Can you please provide some more specific details?  What do I need to do to with the following line so that it would go to the address specified at the memory location APPLICATION_IVT + 0x00.
    asm("goto %0" : : "r"(APPLICATION_IVT + 0x00));
     
    I believe my applications JIVT should be changed to be the following.  Just the address with the lowest 2 bytes first.
        SHORT(DEFINED(__OscillatorFail_1) ? ABSOLUTE(__OscillatorFail_1) :
                    ABSOLUTE(__DefaultInterrupt));
        SHORT(((DEFINED(__OscillatorFail_1) ? ABSOLUTE(__OscillatorFail_1) :
                    ABSOLUTE(__DefaultInterrupt)) >> 16) & 0x7F);
     
    Am I on the correct track?
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5