• AVR Freaks

Hot!PIC18F47K42 Booatloader Interrupt Vector Remap

Author
ahallaj
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2020/01/17 00:19:12
  • Location: 0
  • Status: offline
2020/01/17 22:17:32 (permalink)
0

PIC18F47K42 Booatloader Interrupt Vector Remap

I'm using PIC18F47K42 mc with MPLAB XIDE and XC8 compiler.  I'm working on a bootloader.
I'm having a problem with interrupts not working (i.e. ISR not getting called) after program jumps from bootloader to application.   According to the documentation and discussion forums, because PIC18 supports programming interrupt vector base address into the interrupt controller, remapping of interrupt vectors is basically done by changing the base interrupt vector. For the bootloader, the base interrupt vector is 0x08 and for the program application it is 0x3708.  The linker options are also correctly specified and verified the .map file was properly updated to place the bootloader and program application in mutually exclusive areas in the flash.
 
When I run the application standalone (without bootloader) with the same IVT base address (0x3708), interrupts (i.e. timer interrupt) work fine.  When I program the bootloader and application together, the timer interrupt works while in the bootloader but when program jumps to application, the interrupts don't work anymore.  At the start of the application the interrupt controller and other components are initialized and the application IVT base address is written to the controller register.
 
Using the debugger, I placed a breakpoint in the bootloader timer ISR and it appears while in the application and timer interrupt fires off, program jumps to the bootloader ISR instead of the application ISR.
 
Any help is greatly appreciated
#1

3 Replies Related Threads

    Jerry Messina
    Super Member
    • Total Posts : 549
    • Reward points : 0
    • Joined: 2003/11/07 12:35:12
    • Status: offline
    Re: PIC18F47K42 Booatloader Interrupt Vector Remap 2020/01/20 09:40:05 (permalink)
    0
    There's a config setting (IVT1WAY) that can prevent the IVTLOCKED bit from being changed... check that setting.
     
    Also, verify that you're following the IVT UNLOCK sequence to allow writing to the IVTBASE register.
     
    #2
    ahallaj
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2020/01/17 00:19:12
    • Location: 0
    • Status: offline
    Re: PIC18F47K42 Booatloader Interrupt Vector Remap 2020/01/20 22:57:32 (permalink)
    0
    Jerry,
    Thanks for the suggestion. I was so hopping that was the problem but it wasn't.  Interrupts still don't work when it jumps to the application. The way I changed the config bit was by modifying device_config.c
    #3
    ahallaj
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2020/01/17 00:19:12
    • Location: 0
    • Status: offline
    Re: PIC18F47K42 Booatloader Interrupt Vector Remap 2020/01/20 23:11:50 (permalink)
    +1 (1)
    I found the issue...  In the application code, I was using the microchip MCC generated code for the interrupt controller initialization.  The MCC generated code initialize the IVTAD register as following:
     
    IVTADU = 0;
    IVTADH = 64;
    IVTADL = 8;
     
    This was working when I ran the application standalone without the bootloader, but it didn't work when bootloader ran first.
     
    After changing IVTAD to IVTBASE register to initialize the IVTBase address, interrupts in the application started working
     
    IVTBASEU = 0;
    IVTBASEH = 64;
    IVTBASEL = 8;
     
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5