• AVR Freaks

Hot!accessing Status register on PIC32MZ

Author
mattgreig
Starting Member
  • Total Posts : 82
  • Reward points : 0
  • Joined: 2003/11/07 12:39:01
  • Status: offline
2019/07/22 15:20:10 (permalink)
0

accessing Status register on PIC32MZ

hello,
 
I need to be able to set CPU priority to a particular level for brief moment.
I used to do this on PIC24E via SRbits.IPL = XX
 
i see this is in Status register in PIC32, but if i type Statusbits.IPL, compiler seems to not not about it
 
any clues?
or a better way of changing CPU IPL
 
Thanks
 
 

Matt Greig
Research Associate
PART Group
BCIT Technology Centre
Burnaby,BC, Canada
#1

6 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 18061
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: accessing Status register on PIC32MZ 2019/07/22 15:32:23 (permalink)
    0
    The PIC32 is a MIPS core it does not work like a PIC24 core.
    what are you actually trying to do?  Why do you need to change priority?  If it is to disable interrupts, You can do that directly on the PIC32.
    #2
    aschen0866
    Super Member
    • Total Posts : 4511
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: accessing Status register on PIC32MZ 2019/07/22 15:35:51 (permalink)
    0
    See compiler user guide section 7.7.3.

     
    #3
    aschen0866
    Super Member
    • Total Posts : 4511
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: accessing Status register on PIC32MZ 2019/07/22 15:39:47 (permalink)
    0
    NKurzman
    The PIC32 is a MIPS core it does not work like a PIC24 core.
    what are you actually trying to do?  Why do you need to change priority?  If it is to disable interrupts, You can do that directly on the PIC32.


    I think the OP wants to disable certain level of interrupt by raising up the CPU's IPL. 
     
    Example code extracted from Harmony's FreeRTOS support

    #define portDISABLE_INTERRUPTS() \
    { \
    uint32_t ulStatus; \
    \
    /* Mask interrupts at and below the kernel interrupt priority. */ \
    ulStatus = _CP0_GET_STATUS(); \
    \
    /* Is the current IPL below configMAX_SYSCALL_INTERRUPT_PRIORITY? */ \
    if( ( ( ulStatus & portALL_IPL_BITS ) >> portIPL_SHIFT ) < configMAX_SYSCALL_INTERRUPT_PRIORITY ) \
    { \
    ulStatus &= ~portALL_IPL_BITS; \
    _CP0_SET_STATUS( ( ulStatus | ( configMAX_SYSCALL_INTERRUPT_PRIORITY << portIPL_SHIFT ) ) ); \
    } \
    }

    #4
    NKurzman
    A Guy on the Net
    • Total Posts : 18061
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: accessing Status register on PIC32MZ 2019/07/22 17:03:45 (permalink)
    0
    aschen0866
    I think the OP wants to disable certain level of interrupt by raising up the CPU's IPL. 
     

    I think you are correct.
    But the PIC24 has an odd way of disabling all interrupts.   By changing the IPL.  This is not needed with PIC32 it has 
    __builtin_disable_interrupts();  
    So without knowing what the actual goal is, it is just guessing.
     
    #5
    mattgreig
    Starting Member
    • Total Posts : 82
    • Reward points : 0
    • Joined: 2003/11/07 12:39:01
    • Status: offline
    Re: accessing Status register on PIC32MZ 2019/07/23 07:58:05 (permalink)
    0
    I want to disable certain levels of ISR, not just kill them all.
     
    aschen0866, thanks, i will give this a try

    Matt Greig
    Research Associate
    PART Group
    BCIT Technology Centre
    Burnaby,BC, Canada
    #6
    mattgreig
    Starting Member
    • Total Posts : 82
    • Reward points : 0
    • Joined: 2003/11/07 12:39:01
    • Status: offline
    Re: accessing Status register on PIC32MZ 2019/07/23 09:15:47 (permalink)
    0
     
    looks easier to use __builtin_set_isr_state(New_State_Setting); to assign a new state, ans using the get_isr_state to save and restore later
     
    using this resolved issue I was having
    post edited by mattgreig - 2019/07/23 09:21:24

    Matt Greig
    Research Associate
    PART Group
    BCIT Technology Centre
    Burnaby,BC, Canada
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5