Jan-Erik, I think I finally understand it. In the ISR I only need the=20 instruction count++. It will be updated automatically every time the=20 timer overflows. Either before I call the delay function I need to reset=20 the timer or I need to reset the timer inside the delay function just=20 before I enter the loop. I think resetting the timer in the delay=20 function would be a better choice as I only need to put these=20 instructions in one time. Otherwise I would need to put the instructions=20 in as many times as I call the delay routine. So I would do it this way. //Global variables int count =3D 0; void main(void) { PORTA =3D 0; // Turn porta off TRISA =3D 255; // Set Porta as all inputs PORTC =3D 2; // Set RC1 is high, all other ports are low TRISC =3D 193; // RC1 -RC5 are outputs CMCON0 =3D 7; // Turn off Comparators ANSEL =3D 16; // Set RC0/AN4 as analog // Define commands int DP =3D 1 * 2; int Reset =3D 32 + DP; int GateOn =3D 16 + DP; int GateOff =3D DP; while (1 =3D=3D 1) // Loop forever { PORTC =3D Reset; // Clear the Display PORTC =3D GateOn; // Start counting delay(1); // Count the frequency for one=20 second =3D HZ PORTC =3D GateOff; delay(15); // Display the frequency for 15=20 seconds } } // End NewControlCode.c void delay(int time) { resettimer(); count =3D 0; while(count <=3D time * 10) { } return; } void resettimer(void) { TMR1H =3D 0x0B; TMR1L =3D 0xDC; } I believe that this is the way to do it. What do you think? I'm sorry=20 about confusing you. What I did was use the varuable time in the actual=20 code but I used numberseconds in the peusdocode. Again sorry about that.=20 In C you can have an empty for(); statement if you want to. This will=20 compile and run. I believe that it takes 3 instruction cycles. You can=20 use this to set up a delay loop instead of using NOPs. Thanks, rich! On 7/21/2014 1:59 AM, Jan-Erik Soderholm wrote: > > Richard R. Pope wrote 2014-07-21 07:15: >> Jan-Erik, >> I am using a function that I pass a value to that represents the >> number of seconds that I want the delay to last. I multiply this number >> by ten in the for loop since there are 10 100ms interrupts for a second. >> So if I pass 1 to the delay function, count will be tested for the >> number 10. This is one second. If I call delay again and this time I >> pass 15 to it, count will be tested for the number 150 and this is 15 >> seconds. > --=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 .