Richard, I think you are getting there but there are a few details you missed. I've never seen a for loop used like this but it looks like it should work. I would reset count and use a while loop to wait for the incrementing. What you missed is that resetting count is only part of the reset. This is the 10ths of a second. Meanwhile you don't know where the clock is and will probably miss part of the first cycle. To get accurate timing you need to stop the clock with the enable bit, reset the clock high and low registers, and reset count. Then use the Clock Enable Bit to accurately restart the clock, wait for count to increment, etc. Putting some of this inside the ISR can be more efficient and even more accurate as you may eliminate various call and return functions. Allen > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf Of > Richard R. Pope > Sent: Sunday, July 20, 2014 5:23 AM > To: Microcontroller discussion list - Public. > Subject: Re: [Pic] Making a special timer! >=20 > Jan=3DErik, > I think I finally understand. I did this. > Reset display; > Turn the Gate on; > call delay(numberseconds); //This will be for one second > Turn the Gate off; >=20 > call delay(numberseconds); again /This will be for 15 seconds. > do forever >=20 > delay(numberseconds) > { > for(count =3D 0; count <=3D numberseconds*10;); > return; > } >=20 > interruptcode goes here. >=20 > void Interrupt() > { > if (TMR1IF_bit) > { > TMR1IF_bit =3D 0; > TMR1H =3D 0x0B; > TMR1L =3D 0xDC; > count++; //This increments the count variable > which was declared as global. > } > } >=20 > It compiles. Now I have to test it and see what the output is. If this works I'll > then add the pot and the ADC so that the display time can be varied. I'm getting > there. > Thanks, > rich! > P.S. Allen this also uses your suggestion. > Thanks, > rich! >=20 > On 7/19/2014 4:39 PM, Jan-Erik Soderholm wrote: > > > Jan-Erik, > > > The interrupt happens every 100mS. So for a one second delay I need > > > to execute ten interrupts. > > > > No, that is done automaticly. You doesn't have to > > do anything, the 10 interrupts will happen each > > 1 second by the hardware. > > > > > But I just don't understand how to do this. > > > > You don't have to do anything. Just let your interrupts > > >=20 > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .