Hi

Q1: if I need the counter to count 1 second. Do I need to check for overflow, thus configuring TMR1 to 0xFFFF-....?

Q2: I wrote the following code, but it seems it only works once and I need the timer to restart. What am I doing wrong?

void timer1(unsigned short val)
{
TMR1ON = 0;
TMR1IF = 0;
TMR1 = val;
T1CON = 0xC8;//0b11001000
TMR1ON = 1;

while(!TMR1IF)
;
}

void main(void)
{
TRISD = 0x00;//output
PORTD = 0x00;

while(1)
{
PORTD = 0x01;
timer1(0xFFFF-0x8000);
PORTD = 0x08;
timer1(0xFFFF-0x8000);
}
}