Hi to all engineers, I was testing timer0 on 18f242 using ICE2000 emulator for Some reason the code quits running after a few seconds. Does my code look correct? /**************************************************** * Timer0 test code: pic18f242 * Andre Abelian: * 7:15:2003 * Hi-Tech compiler: ****************************************************/ #include #include "delay.c" #define PORTBIT(adr, bit) ((unsigned)(&adr)*8+(bit)) static bit led1 @ PORTBIT(PORTB, 0); static bit led2 @ PORTBIT(PORTB, 7); // function decaration void init(void); // main program void main(void) { init(); // setup all while(1); } /* interrupt isr */ static void interrupt isr(void) { if (TMR0IF) { TMR0IF=0; // clear interrupt flag led1^=0x01; } } /* * Init All * */ void init(void) { TRISB=0x00; // all portb output TRISA=0xFF; // all porta all input PORTB=0x00; // make sure all leds off PORTC=0xFF; // all portc output /* * timer0 setup: * */ TMR0ON=1; // timer0 on T08BIT=1; // timer0 is in 8 bit mode T0CS=0; // internal instruction cycle clock T0SE=1; // increment on high to low PSA=0; // timer0 prescaler is assigned T0CON|=0x07; // 1:256 prescale value /* * INTCON Register setup: * */ GIE=1; // Global Interrupt enable PEIE=1; // enable peripheral interrupt TMR0IE=1; // enable TMR0 interrupt INT0IE=0; // disable the INT0 external RBIE=0; // disable Port on change } any help will appreciate. Andre -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu