CPU interrupt priority

Discussion in 'Embedded Systems and Microcontrollers' started by chrisw1990, Apr 14, 2012.

  1. chrisw1990

    Thread Starter Active Member

    Oct 22, 2011
    543
    41
    ermmm pic32mx795f512l
    i want to set up an external interrupt to wake it from sleep, to do this, i need to set the extint priority above the cpu..
    but i dont know where the cpu vector is? nor what its default is.. nor if i can just set it to one below the highest and that be it.. make sense?
    ta
     
  2. panic mode

    Senior Member

    Oct 10, 2011
    1,321
    304
    what does the manual says?
     
  3. chrisw1990

    Thread Starter Active Member

    Oct 22, 2011
    543
    41
    no idea.. maybe im looking for the wrong thing.. but pic32mx795f512l datasheet doesnt mention cpu priority..
     
  4. nsaspook

    AAC Fanatic!

    Aug 27, 2009
    2,912
    2,177
  5. chrisw1990

    Thread Starter Active Member

    Oct 22, 2011
    543
    41
    iv looked in there, thats what im saying, i think im looking for the wrong interrupt name, im looking for anything referring to cpu priority, but that must be wrong, the cpu is such a vague thing to say
     
  6. panic mode

    Senior Member

    Oct 10, 2011
    1,321
    304
    i've been using pic24s, should be similar:

    vector table is at the begin of addressable memory.
    there are variety of interrupt sources, external ones are either INT0 INT1... or Change Notification.
    Interrupt priority is 1..7. higher value is higher priority.
     
  7. chrisw1990

    Thread Starter Active Member

    Oct 22, 2011
    543
    41
    yeh, i was looking at the table again today, i reckon im just overcomplicating things, should try it out, and if it doesnt wake the device up properly then hit it with a hammer...
     
  8. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,607
    It would help to know what compiler you are using. Should it happen to be the C32 compiler there are library functions for this. Details can be found in the help file located at ...\Microchip\mplabc32\v2.01\doc\pic32-lib-help\INT-PLIB-Help.chm

    Here's a sample of how a timer interrupt looks:

    Code ( (Unknown Language)):
    1. /////////////////////////////////////////////////////////////////////////////
    2. // Function: Timer3 ISR
    3. // Input: none
    4. // Output: none
    5. // Overview: increments tick counter. Tick is approx. 1 ms.
    6. /////////////////////////////////////////////////////////////////////////////
    7.     #define __T3_ISR    __ISR(_TIMER_3_VECTOR, ipl4)
    8.  
    9. /* */
    10. void __T3_ISR _T3Interrupt(void)
    11. {
    12.     // Clear flag
    13.     mT3ClearIntFlag();
    14.     // do something useful
    15.     UsefulFunction();
    16. }
     
  9. chrisw1990

    Thread Starter Active Member

    Oct 22, 2011
    543
    41
    hi ernie.. im using c32, but the problem i thought i might have is that to wake the device up from sleep, (OSCCON SLPEN) i need to make sure that the wake up source (external interrupt) is a higher priority than the CPU...if it isnt, then it wont wake the device up,
    ta for the code though, hadnt considered using a #define t make the isr easier.
     
  10. panic mode

    Senior Member

    Oct 10, 2011
    1,321
    304
    you can assign priority to any interrupt.

    Code ( (Unknown Language)):
    1. void  configTimer3(void) {
    2.   //ensure that Timer2,3 configured as separate timers.
    3.   T2CONbits.T32 = 0;     // 32-bit mode off
    4.   //T3CON set like this for documentation purposes.
    5.   //could be replaced by T3CON = 0x0030
    6.   T3CON = T3_OFF | T3_IDLE_CON | T3_GATE_OFF
    7.           | T3_SOURCE_INT
    8.           | T3_PS_1_256 ;  //results in T3CON= 0x0030
    9.   //PR3 = msToU16Ticks (ISR_PERIOD, getTimerPrescale(T3CONbits)) - 1;
    10. PR3=0xFFFF;
    11.   TMR3  = 0;                       //clear timer3 value
    12.   _T3IF = 0;                       //clear interrupt flag
    13.   _T3IP = 2;                       //choose a priority
    14.   _T3IE = 1;                       //enable the interrupt
    15.   T3CONbits.TON = 1;               //turn on the timer
    16. }
    17.  
     
Loading...