• AVR Freaks

ISR shadow register confusion

Author
henkebenke
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2008/09/27 23:55:51
  • Location: 0
  • Status: offline
2020/01/24 09:32:34 (permalink)
0

ISR shadow register confusion

Sorry to bother you, but this pic32mz0512efe100 is a monster.
 
I have made basic configurations via the harmony framework.  I have now set up the SPI with my own settings and it works.
But when I change the ISR definition from:
void _ISR (_SPI1_RX_VECTOR, ipl4AUTO) SPI_Handler (void)
 
to
 
void _ISR (_SPI1_RX_VECTOR, ipl4SRS) SPI_Handler (void)
 
the program crashes. I have set the IPL level to 4. I read somewhere in the Help-window that if SRS should be used, one must configurate the CPU so that a certain SRS will be assigned to a specific IPL level.
Now, I really don't get that AUTO setting. Even though there only are a couple of timer interrupts in my program, the compiler doesn't seem to use the shadow regs. What's the point with this AUTO thing, when in reality, software backups will be done to 100%?
For me, the choice of a pic32 comes to speed, and it seems totally insane to have interrupts that spends some 200 instructions on context savings.
Can some nice and clever person describe this for me? And perhaps give a hint of how I can make the device use the shadow registers. Thanks.
#1

4 Replies Related Threads

    nigelwright7557
    Super Member
    • Total Posts : 342
    • Reward points : 0
    • Joined: 2006/11/06 08:15:51
    • Location: 0
    • Status: offline
    Re: ISR shadow register confusion 2020/01/24 10:10:17 (permalink)
    0
    Sorry if my answer is a little naive and i could be wrong but I believe IPL7 automatically uses shadow registers.
     
    #2
    simong123
    Lab Member No. 003
    • Total Posts : 1356
    • Reward points : 0
    • Joined: 2012/02/07 18:21:03
    • Location: Future Gadget Lab (UK Branch)
    • Status: offline
    Re: ISR shadow register confusion 2020/01/24 10:41:29 (permalink)
    5 (2)
    nigelwright7557
    Sorry if my answer is a little naive and i could be wrong but I believe IPL7 automatically uses shadow registers.

    That is not correct.
     
    On the MZ you have to configure the PRISS register to allocate shadow sets to interrupt levels manually.
    PRISS=0x76543210 is a good option (Shadow set No. = IPL).


     
    Edit: If your interrupt routine is spending 200 instr. on context saving than something is wrong. It should be noted that there are no shadow sets for the FPU registers so if you call any functions outside the compilation uint from within the ISR (e.g. callbacks), the full FPU state is saved since the compiler cannot determine if the FPU is in use or not. If you are sure that you are not using the FPU during an interrupt then add the nofpu attribute to the interrupt routine.
    post edited by simong123 - 2020/01/24 10:46:29
    #3
    jdeguire
    Super Member
    • Total Posts : 499
    • Reward points : 0
    • Joined: 2012/01/13 07:48:44
    • Location: United States
    • Status: offline
    Re: ISR shadow register confusion 2020/01/24 10:44:27 (permalink)
    0
    Make sure you set the PRISS register to 0x76543210 early on in your code.  Newer versions of XC32 might already do this for you, but it's worth at least verifying this.
     
    Also, if you have a look at the XC32 Users Guide (in the Docs directory where the compiler is installed), there is a section in there on creating your own exception handlers.  You probably want to do this so you can get more info about why your application is crashing.  You can look at the EPC, BadVAddr, and Cause registers to help determine what went wrong.  If you don't know what those registers are, you should download Section 50 of the PIC32 Family Reference Manual here and have a look at the CP0 Registers section.
    #4
    henkebenke
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2008/09/27 23:55:51
    • Location: 0
    • Status: offline
    Re: ISR shadow register confusion 2020/01/24 11:12:30 (permalink)
    5 (1)
    Thank you guys,  but I actually managed to figure it out by myself and intended to edit my thread.
     
    But I think this may be helpful for others.  And I must add one thing.  If there are 7 levels and seven shadow registers, why aren't they hardcoded to their optimal setting ( PRIS = 0x76543210)?
    Perhaps for compatibility with other processors that has fewer shadows.
     
    I must now complain about the sanity of the Harmony designers. I have spent almost two days on the following issues. 
    1. Harmony disables every peripheral that is not configurated in Harmony, and it is done in the clock settings, with some cryptic PMDn settings. This is pure sadism!
     
    2. As mentioned, why can't Harmony initiate PRISS to the optimal value?
     
    3. It was impossible to initiate SPI1 as slave.
     
    4. etc...
     
     
    They have probably spent 10000 man hours on that framework. The settings are spread out over hundreds of files and it's hard to get an overview. A fairly simple thing as to set up an I2S slave is absolutely scaring. The abstraction is just too high.  
    Some things are complex.  One has the choice to; 1. try to grasp the situation, and spend time on learning how things work or; 2. Try to figure out how a complex framework behaves.
    For me, the choice is simple.  
     
    But....
     
    I must admit that Harmony is perfect for setting up the device the first time.
     
     
     
    #5
    Jump to:
    © 2020 APG vNext Commercial Version 4.5