• AVR Freaks

Hot!Erroneous compiler error

Author
nice
Super Member
  • Total Posts : 1069
  • Reward points : 0
  • Joined: 2004/09/18 11:42:25
  • Location: Germany
  • Status: offline
2019/05/29 11:53:23 (permalink)
0

Erroneous compiler error

Compiler: XC16 1.36
Devices: dsPIC33CH128MP508 and dsPIC33CH512MP508
 
Test code:
void __attribute__ ((interrupt, context, no_auto_psv)) _ADCAN7Interrupt (void)
{
    ADCBUF7;
    _ADCAN7IF = 0;
}


The above code compiles fine for the master core of aforementioned devices, but it throws an error if the target is the slave core:
code/App/src/main_slave.c:313:1: error: Currently selected device does not support context regsiters


I’m quite sure that the slave core has four sets of alternate working registers. At least I can configure their usage via the configuration bits:

// FS1ALTREG
#pragma config S1CTXT1 = IPL7           // Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 1 bits (Alternate Register set assigned to IPL level 7)
#pragma config S1CTXT2 = IPL6           // Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 2 bits (Alternate Register set assigned to IPL level 6)
#pragma config S1CTXT3 = IPL5           // Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 3 bits (Alternate Register set assigned to IPL level 5)
#pragma config S1CTXT4 = IPL4           // Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 4 bits (Alternate Register set assigned to IPL level 4)

Hence I’d guess the compiler is in error…
#1

2 Replies Related Threads

    nice
    Super Member
    • Total Posts : 1069
    • Reward points : 0
    • Joined: 2004/09/18 11:42:25
    • Location: Germany
    • Status: offline
    Re: Erroneous compiler error 2019/05/29 13:24:52 (permalink)
    0
    Reported under case number 00422153.
    #2
    nice
    Super Member
    • Total Posts : 1069
    • Reward points : 0
    • Joined: 2004/09/18 11:42:25
    • Location: Germany
    • Status: offline
    Re: Erroneous compiler error 2019/06/18 12:44:09 (permalink)
    0
    Suggested workaround from support: Use "naked" instead of "context":

    The 'context' attribute is functionally equivalent to the 'naked' attribute except that 'context' still will save accumulator registers and any C variables indicated with the 'save' attribute in interrupt functions.
    The context attribute tells the compiler that there is a user defined context for this ISR and
    the device will do a context swap to another set of registers.
    This means that the compiler does not need to save any registers unless there is a 'save' attribute or  there are accumulator registers being used.
    
Therefore if the you do not use accumulators or save attribute in the ISR nor has marked any C variables with the 'save' option for the interrupt function, then 'naked' is functionally equivalent.


    Please note that "naked" will also work if using the accumulators in the ISR, as dsPIC33Cs do provide four additional accumulator register sets bound to the context in use (at least according to the documentation). If XC 16 does actually save and restore the accumulators in an ISR containing the context attribute on a dsPIC33C master core, it would be a waste time.


    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5