CPU interrupt priority

Thread Starter

chrisw1990

Joined Oct 22, 2011
551
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
 

Thread Starter

chrisw1990

Joined Oct 22, 2011
551
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
 

panic mode

Joined Oct 10, 2011
5,198
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.
 

Thread Starter

chrisw1990

Joined Oct 22, 2011
551
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...
 

ErnieM

Joined Apr 24, 2011
8,415
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:

Rich (BB code):
/////////////////////////////////////////////////////////////////////////////
// Function: Timer3 ISR
// Input: none
// Output: none
// Overview: increments tick counter. Tick is approx. 1 ms.
/////////////////////////////////////////////////////////////////////////////
    #define __T3_ISR    __ISR(_TIMER_3_VECTOR, ipl4)

/* */
void __T3_ISR _T3Interrupt(void)
{
    // Clear flag
    mT3ClearIntFlag();
    // do something useful
    UsefulFunction();
}
 

Thread Starter

chrisw1990

Joined Oct 22, 2011
551
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.
 

panic mode

Joined Oct 10, 2011
5,198
you can assign priority to any interrupt.

Rich (BB code):
void  configTimer3(void) {
  //ensure that Timer2,3 configured as separate timers.
  T2CONbits.T32 = 0;     // 32-bit mode off
  //T3CON set like this for documentation purposes.
  //could be replaced by T3CON = 0x0030
  T3CON = T3_OFF | T3_IDLE_CON | T3_GATE_OFF
          | T3_SOURCE_INT
          | T3_PS_1_256 ;  //results in T3CON= 0x0030
  //PR3 = msToU16Ticks (ISR_PERIOD, getTimerPrescale(T3CONbits)) - 1;
PR3=0xFFFF;
  TMR3  = 0;                       //clear timer3 value
  _T3IF = 0;                       //clear interrupt flag
  _T3IP = 2;                       //choose a priority
  _T3IE = 1;                       //enable the interrupt
  T3CONbits.TON = 1;               //turn on the timer
}
 
Top