ISR(TIMER1_COMP_vect, ISR_BLOCK)
{
    //******************************************************************************
    //  System timer (for system ticks)
    //******************************************************************************

    TCNT1 = 0;    
    OS_Timer();

}
void interrupcao(){

    if (PIR1bits.TMR1IF)
    {
        PIR1bits.TMR1IF = 0;
        TMR1H           = 0xD8;     
        TMR1L           = 0xF0;
        OS_Timer(); //estoura a cada 10.000us (para clock de 4MHz)
    }
}
void interrupt_high (void)
{
    static unsigned char ucCounter;   // PWM steps counter
           unsigned char ucPosition;  // Position for rotation
           unsigned char ucLedsMask;  // Current LED's mask
           char i;          // Loop variable

    //******************************************************************************
    //  Software PWM
    //******************************************************************************
    
    if (INTCONbits.T0IF && INTCONbits.T0IE)
    {
        INTCONbits.T0IF = 0;
        ucCounter++;

        ucPosition = m_ucPosition;    // Position of brightness for first LED

        i = NUMBER_OF_LEDS;         // Loop on all LEDS
        ucLedsMask = 0x01;

        do
        {
            //----------------------------------------------------------------------
            // Check for PWM duty cycle
            // 
            //----------------------------------------------------------------------
            if (ucCounter > Brightness[ucPosition & TABLE_MASK])  PORTLEDS &= ~ucLedsMask;
            else                                                  PORTLEDS |=  ucLedsMask;

            ucLedsMask <<= 1;            // Make mask for next LED
            ucPosition += m_scDirection; // Take next position of brightness


        } while (--i);
        
        ucCounter &= 0x1F;               // PWM is 5-bit, msb are zeroed
    }


    //******************************************************************************
    //  System timer (for system ticks)
    //******************************************************************************
    
    if (PIR1bits.TMR2IF)
    {
        PIR1bits.TMR2IF = 0;
        OS_Timer();
    }

}
Esempio n. 4
0
void interrupt (void)
{
  if(TMR0if_bit)
  {
   tmr0if_bit=0;
   tmr0l=0;
   OS_Timer();
  }
  if(tmr3if_bit)
  {
   tmr3if_bit=0;
   ISR1();
  }
  if(TMR1IF_bit)
  {
   tmr1IF_bit=0;
   tmr1l=0;
   tmr1h=0xAA;
  }
}
void timer0_isr(void){  
   OS_Timer();
   set_timer0(0xE88F);    //se recarga el Timer0   
}