• AVR Freaks

Hot!How to use Legacy Interrupts in for 26K83 in XC8?

Author
crosland
Super Member
  • Total Posts : 1936
  • Reward points : 0
  • Joined: 2005/05/10 10:55:05
  • Location: Warks, UK
  • Status: offline
2020/03/26 13:46:24 (permalink)
0

How to use Legacy Interrupts in for 26K83 in XC8?

26K83, XC8 2.10, MPLAB X 5.35
 
I have a bootloader that I want to port from a 25K80 to 26K83. First time using a device with vectored interrupts.
 
To keep changes to a minimum (but thanks for renaming all the registers and bit, Microchip) I am keeping the legacy interrupts. In the C source I have
 

// High priority interrupt vector @ 0x8
asm("PSECT intcode");
asm("GOTO " ___mkstr(APP_START+0x8));

// Low priority interrupt vector @ 0x18
asm("PSECT intcodelo");
asm("GOTO " ___mkstr(APP_START+0x18));

 
Which results in the following

:0:: warning: (526) psect "intcodelo" not specified in -P option (first appears in "dist/canisb_v1_0_2/production\<redacted>.X.production.o")
:0:: warning: (526) psect "intcode" not specified in -P option (first appears in "dist/canisb_v1_0_2/production\<redacted>.X.production.o")
C:\Users\Daddy\AppData\Local\Temp\s4g8.2::: warning: (1343) hexfile data at address 0x0 (0xFE) overwritten with 0x2C
C:\Users\Daddy\AppData\Local\Temp\s4g8.2::: warning: (1343) hexfile data at address 0x0 (0xFE) overwritten with 0x2C

 
I am guessing XC8 is assuming I am using vectored interrupts and does not create the psects.
 
Is that assumption correct? Where do I find the psect setup in the 25K80 configuration?  How do I apply them to this configuration.
#1

5 Replies Related Threads

    crosland
    Super Member
    • Total Posts : 1936
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: How to use Legacy Interrupts in for 26K83 in XC8? 2020/03/27 08:50:08 (permalink)
    0
    Can anyone help?
     
    I have RTFM a little more. The XC8 User Guide (4.9.3) says that in legacy mode the IVTBASE can be used to map the dual vectors to any address. This should allow me to move the vectors in line with the CODEOFFSET and remove the GOTO instructions in the intcode and intcodelo psects.
     
    The problem is there is no indication how to do this. E.g. do I set it to 0x800 for legacy vectors at 0x808 and 0x818, or...? 
     
    The 26K83 data sheet knows nothing about legacy mode, only a couple of paragraphs on "compatibility", section 9.11. Again no indication how to map the dual vectors for legacy mode.
     
    I even installed MCC but, in non-vectored mode, there is no where to enter a vector base and the generated code gives no hints.
     
    #2
    mbrowning
    USNA79
    • Total Posts : 1741
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: How to use Legacy Interrupts in for 26K83 in XC8? 2020/03/27 09:35:34 (permalink)
    0
    You would change IVTBASE to the first interrupt - 0x808 in your case.
    I've never used legacy mode, but that's my understanding. Here's a thread about this from a few months ago.
    https://www.microchip.com/forums/m1108507.aspx
     
    edit- I'd forgotten, but in that thread I did try turning vectored off. The problem the OP had and I saw also was that with MVECEN off and setting codeoffset non-zero, XC8 puts jumps to interrupt routines at 0x008 and 0x018 unless you add the "base()" option to interrupt functions. You still had to set IVTBASE to get the interrupt vectors changed at run time, but XC8 responded to the base() option.
     
     
    post edited by mbrowning - 2020/03/27 12:22:23
    #3
    NorthGuy
    Super Member
    • Total Posts : 6072
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: How to use Legacy Interrupts in for 26K83 in XC8? 2020/03/27 10:37:05 (permalink)
    0
    crosland
    The problem is there is no indication how to do this. E.g. do I set it to 0x800 for legacy vectors at 0x808 and 0x818, or...? 


    The K42 datasheet says: "00 0008h location is used as the reset default for the IVTBASE register, the vector table can be relocated in the memory by programming the IVTBASE register."
     
    Based on this, I would set it to 0x808.
    #4
    crosland
    Super Member
    • Total Posts : 1936
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: How to use Legacy Interrupts in for 26K83 in XC8? 2020/03/27 13:28:13 (permalink)
    0
    Thanks. With those links I think I understand it.
     
    My main bitch is that I am still struggling to get this info from the data sheet or the XC8 docs. These say that the vector table is disabled in legacy mode, so why would I need to move it? They only half-heartedly tell you that IVTBASE is still active in legacy mode, but not what address to set it to.
    post edited by crosland - 2020/03/27 13:29:21
    #5
    crosland
    Super Member
    • Total Posts : 1936
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: How to use Legacy Interrupts in for 26K83 in XC8? 2020/03/28 04:49:19 (permalink)
    +1 (1)
    I now have something that builds, need to test in hardware.
     
    One further point, I normally include the config words in the bootloader code. It seems essential that, at the very least,

    #pragma config MVECEN = OFF

    Needs to be included in the application, otherwise XC8 tries to build a vector table.
     
    I had to replicate the whole CONFIG2L/Hh settings in my app to avoid mismatches. 
     
    I've added a similar not to the other thread in the hope it will help in the future.
     
    Thanks again.
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5