C18, PIC18F252: Setting timer0 with an interrupt ?

From: Rodo (dsp1024_at_yahoo.com)
Date: 01/24/04

Date: Sat, 24 Jan 2004 04:29:02 GMT

Hi all...

I'm trying to set up timer0 to time about 10ms and inc a global variable
that gets displayed on an LCD. Everything is pretty much working except that
I can't change the time out value for timer0. I init the timer before a
while loop that display the variable "time". The isr inc the value on every
time out of timer0. It also toggles RB4 so I can check the freq (for
testing). The freq is always about 4 Hz.
TIME_TIMEOUT is defined as 5000. I've tried to change this value but nothing
happens. What am I missing ?


BTW it runs at 2MHz. There is only one isr.

//------------- code begins --------------------------
 OpenTimer0(TIMER_INT_ON & T0_16BIT & T0_SOURCE_INT & T0_PS_1_1);

// INTCON=0; //make sure interrupts are disable
// INTCONbits.GIE=1; //enable global interrupts
// INTCONbits.PEIE=1; //enable peripheral interrupts
// INTCONbits.TMR0IE=1; //enable TMR0 overflow interrupt enable bit
 INTCON=0xe0; //all 4 lines above combined

  SetDDRamAddr(LCD_LINE2); // Display value of time
  while(BusyXLCD()); // Wait if LCD busy

//--------------- code ends ----------------------

The isr is here:

//------------- code begins ----------------------
#pragma code
#pragma interrupt InterruptHandlerLow
void InterruptHandlerLow()
 if (INTCONbits.TMR0IF==1)
   INTCONbits.TMR0IF=0; //clear interrupt flag

//--------------- code ends ----------------------