I'm trying to grasp the functionality of tmr0 interrupt. I have written a basic tmr0 interrupt based c code. (I used hi-tech picc compiler in my testings) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include __CONFIG(XT & WDTDIS); void interrupt tmr0_isr (void) { RB0 ^= 1; T0IF = 0; TMR0 = 255; } void main (void) { PSA = 1; // prescalar assigned to the WDT T0CS = 0; // select internal clock T0IE = 1; // enable timer interrupt GIE = 1; // enable global interrupts TRISB0 = 0; RB0 = 0; TMR0 = 255; // Load the tmr0 for the minimum interrupt rate while(1); } // All the calculations are based on 4 MHZ XT. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Above i would expecting the toggle rate of RB0 is about 1 us + 2us (synch cycles) + a few more for interrupt latency which is totally about 5 us. But when i tested the rate with MPLAB stopwatch i get an interrupt at each 18us. So the tmr0_init_value = 256 - (delay_time * clock_freq/4) dont work with my tmr0 calculations. (assumed no prescaler). So where am i misunderstanding, is this the problem of c compiler or me? -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist