Hot!Problem with IPL bits

Author
liebart
New Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2010/05/27 01:38:14
  • Location: 0
  • Status: offline
2017/10/05 08:28:51 (permalink)
0

Problem with IPL bits

Hello,
 
In Interrupt functions, I use to increase the IPL bits, just to make sure that any other interrupt, with higher priority, will interrupt an important calculation (with the DSP Engine for instance)
My code looks like that (I store the current layer and restore it after the calculation)
uchar_ipl=SRbits.IPL;
SRbits.IPL=7;
DSP_SQ115
y_tab[1]=sq115_err;
sq115_com=DSP_EQDIM(x_tab,y_tab,3);
y_tab[0]=sq115_com;
y_tab[2]=y_tab[1];
SRbits.IPL=uchar_ipl;
 
I did not have any problem with this method yet.
 
But today, in a same interrupt function, I wanted to do it twice.
For the first, this code works:
DSP_SQ115
uchar_ipl=SRbits.IPL;
SRbits.IPL=7;
sq115_PosFilt=DSP_EQDIM(x_FIRtab,y_FIRtab,DIM_FIR);
uint_cmpt++;
SRbits.IPL=uchar_ipl;
 
But this doesn't work:
DSP_SQ115
uchar_ipl=SRbits.IPL;
SRbits.IPL=7;
sq115_PosFilt=DSP_EQDIM(x_FIRtab,y_FIRtab,DIM_FIR);
SRbits.IPL=uchar_ipl;
uint_cmpt++;


When runing with the debugger, MPLABX says : 
"Target halted due to Software Breakpoint in user code"
 
Can anyone help me ?
Thank you.
Vincent
 
 
 
 
 
 
#1

10 Replies Related Threads

    liebart
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2010/05/27 01:38:14
    • Location: 0
    • Status: offline
    Re: Problem with IPL bits 2017/10/06 02:08:04 (permalink)
    3 (2)
    I resolved my problem with a more appropriate method to restore the IPL bits:
     
    uint_SRMask=SR&0x00E0; // sauvegarde des bits IPL
    SRbits.IPL=7; // élévation du niveau courant
    sq115_PosFilt=DSP_EQDIM(x_FIRtab,y_FIRtab,DIM_FIR);

    SR=(SR&0xFF1F)|uint_SRMask; // restauration des bits IPL (on force à 0 les bits à restaurer puis on restaure)
    #2
    Aussie Susan
    Super Member
    • Total Posts : 2904
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Problem with IPL bits 2017/10/08 19:08:07 (permalink)
    4 (2)
    Glad you have a working solution but I'm more interested in why you feel you need to play with the priority bits inside an ISR?
    Why not just set the priority of the ISR vector and let that handle the processor priority for you?
    Susan
    #3
    liebart
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2010/05/27 01:38:14
    • Location: 0
    • Status: offline
    Re: Problem with IPL bits 2017/11/07 09:31:59 (permalink)
    0
    Sorry Susan, I didn't see your answer !! (I 've just logged to post another issue)
     
    I Modify the current level because DSP_EQDIM is an assembler function, which has to be not interrupted. For instance, if another Interrupt function appears during this function, it may change the contents of Wx and REPEAT registers. These registers will not be retored.
    #4
    qhb
    Superb Member
    • Total Posts : 6255
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Problem with IPL bits 2017/11/07 12:43:51 (permalink)
    0
    So why not give this interrupt the highest priority to start with?
    #5
    liebart
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2010/05/27 01:38:14
    • Location: 0
    • Status: offline
    Re: Problem with IPL bits 2017/11/08 00:29:23 (permalink)
    0
    Not possible in my programm: other assembler function appear in other Interrupt functions
     
    (sorry for my english ... I'm french, and as many french people I do not speak other languages very well)
    #6
    Aussie Susan
    Super Member
    • Total Posts : 2904
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Problem with IPL bits 2017/11/08 17:42:30 (permalink)
    3 (1)
    I suspect there is a major misunderstanding somewhere (and nothing to do with english or French).
    Exactly which device are you programming? I suspect it must be a dsPIC33 or PIC24 family device if you are talking about the IPL bits.
    If that is the case then each interrupt source has its own priority and this is the setting that we say you need to set to achieve what you want. The registers are probably called 'IPCx' or something similar.
    Also this is a capability of the device itself, and nothing to do with your code being written in assembler (or any other language).
    The other alternative is that we completely misunderstand how you have coded your app and so showing some of your code would help us there.
    Susan
    #7
    NorthGuy
    Super Member
    • Total Posts : 4525
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Problem with IPL bits 2017/11/08 20:05:43 (permalink)
    0
    What is the reason you don't want to save/restore the necessary W registers and RCOUNT upon entering the interrupt?
     
    Also, some dsPICs have shadow registers sets, so you don't need to save W registers. Perhaps, yours is one of them.
    #8
    liebart
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2010/05/27 01:38:14
    • Location: 0
    • Status: offline
    Re: Problem with IPL bits 2017/11/14 09:39:57 (permalink)
    0
    Hello Susan and "NorthGuy"
    Here in attached file I show the principle of my programm (for DSPIC33FJ)
    - the main function does not do anything but initializations
    - there is a function which uses the DSP engine. Before any computation, the DSP must be configured (Macro A = unsigned integer)
    - there are 2 Interrupt functions: ADC (priority = 3) and PWM Match (Priority = 6) These two functions use the DSP engine too, but with another configuration (Macro B= signed fractionnal SQ1.15), and call the mentioned function
     

     
     
     
    If I don't put the IPL at 7 in the function before the macro (I restore it after the DSP computation), an interrupt may occur after the Macro A. In the interrupt, the DSP will be configured with the Macro B, and the good configuration will not be restore for the computation in the function.
     
    Without this configuration issue, I must admit that I would disable interruptions before any DSP computation (in anassembler file), because I'm not sure that RCOUNT and Working Registers will be restored at the return of an interruption. Can you tell me exactly what is restored by the compiler (XC16) at the return of an interruption ?
    Down here an example of my interrupt function prototypes:
    void __attribute__((__interrupt__,__no_auto_psv__)) _CNInterrupt(void);
     
     
    #9
    Aussie Susan
    Super Member
    • Total Posts : 2904
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Problem with IPL bits 2017/11/14 19:31:28 (permalink)
    3.5 (2)
    I would suggest that you redesign your code as it could well be that the ISRs are taking a while to execute - especially of you have to perform DSP functions.
    In general, calling a function within an ISR will force the compiler to save/restore all registers because it has no idea (as it is compiling the ISR code) what registers will be used by the called function. 
    I can't tell you exactly whether the RCOUNT or any other specific register is saved but have a look at the generated assembler and you will see the pre-amble and post-amble code that is generated.
    Personally I use the ISR code to set flags or perform very short/simple operations. Performing lengthy code sequences is best left for the main loop.
    Susan
    #10
    liebart
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2010/05/27 01:38:14
    • Location: 0
    • Status: offline
    Re: Problem with IPL bits 2017/11/15 10:12:15 (permalink)
    0
    Hello Susan,
     
    I've been hesitating to do such changes in my programm. I think I will do so
     
    I really do appreciate to talk with you. You are always hepful.
     
    Speak you soon I hope.
     
    Vincent (from France)
    #11
    Jump to:
    © 2017 APG vNext Commercial Version 4.5