Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/23/11 16:57
Read: times


 
#182344 - Another Thought...
Responding to: ???'s previous message
It can be highy advantageous to use an alternate register set for interrupt routines. You would declare a timer interrupt routine like shown here to allow the timer ISR to use register set #1.

void timer2_isr(void) interrupt 5 using 1      
{
    TF2H = 0;                           /* Clear Timer2 interrupt flag */

    /* ... */
    /* whatever other real work you use the timer interrupt for can go here */
    /* ... */
}

You also need to make real sure that if the ISR code calls any other functions that they are also declared with the "using 1" attribute. These other functions should not be called by the mainline code which is presumably using register set #0 by default.

A side note is that it is not a very good idea for ISR code to call library functions. Some are re-entrant and others may not be. I have generally found it to be easiset to just code up whatever special functions the Interrupt routine needs and tag them with "using 1".

You may want to also enable the use of register set #2 for cases where there are interrupt routines enabled as higher and lower priority wherein a lower priority ISR can be interrupted by a higher priority one.

Michael Karas


List of 13 messages in thread
TopicAuthorDate
PCA 8051 issue            01/01/70 00:00      
   CCF4 Bit            01/01/70 00:00      
      CCF4 bit            01/01/70 00:00      
         run_mode??            01/01/70 00:00      
            interrupt vectors            01/01/70 00:00      
               interrupt vectors            01/01/70 00:00      
            run_mode            01/01/70 00:00      
   Now seems like....            01/01/70 00:00      
      Goes for all languages/platforms            01/01/70 00:00      
      my code            01/01/70 00:00      
         No....            01/01/70 00:00      
   just a thought            01/01/70 00:00      
   Another Thought...            01/01/70 00:00      

Back to Subject List