Beispiel #1
0
void interrupt ISRCode( )
{
 // keyInterrupt();
  timerInterrupt( );
 // timer2Interrupt();
//  timer4Interrupt();
 // timer6Interrupt();
}
/*
* Hardware interrupt.
*/
void interrupt(){
  if (TMR0IF_bit){
    TMR0IF_bit         = 0;
    TMR0         = 100;
    
    timerInterrupt();
  }
}
Beispiel #3
0
int main(void)
{
uchar   i;

    wdt_enable(WDTO_1S);
    odDebugInit();
    DDRD = ~(1 << 2);   /* all outputs except PD2 = INT0 */
    PORTC = 0xFF;  /* internall pullup */ 
    DDRC = 0;  /* portc all inputs  */
    PORTD = 0;
    PORTB = 0;          /* no pullups on USB pins */
/* We fake an USB disconnect by pulling D+ and D- to 0 during reset. This is
 * necessary if we had a watchdog reset or brownout reset to notify the host
 * that it should re-enumerate the device. Otherwise the host's and device's
 * concept of the device-ID would be out of sync.
 */
    DDRB = ~USBMASK;    /* set all pins as outputs except USB */
    ledstatus= 0xAA;
    usbDeviceDisconnect();  /* enforce re-enumeration, do this while interrupts are disabled! */
    i = 0;
    while(--i){         /* fake USB disconnect for > 500 ms */
        wdt_reset();
        _delay_ms(2);
    }
    usbDeviceConnect();
    TCCR0 = 5;          /* set prescaler to 1/1024 */
    usbInit();
    sei();
    for(;;){    /* main event loop */
        wdt_reset();
        usbPoll();
        if(TIFR & (1 << TOV0)){
            TIFR |= 1 << TOV0;  /* clear pending flag */
            timerInterrupt();
        }
    }
    return 0;
}