Well, now... :-) The *Mikroelektronika* code generator is (probably) not doing anything wrong! But it generates code for *MikroC*, the compiler from *Mikroelektronika*, of course! Why should *they* generate code for the XC8 compiler!? Is there any specific reson you are using a code generator for another compiler!? This might also be the reason I was not sure from the start what compiler you used. :-) > Watch out for the calculator. It is not correct for XC8. I expect the *stopwatch* in the simulator in MPLAB X to count cycles based on the generated assembler code. That has very little to do with XC8 as such. Can you be more specific on what "calculator" you are talking about ? Regards, Jan-Erik. Richard R. Pope wrote 2014-07-23 19:23: > Jan-Erik, > Yep, that was the problem. The gate and the reset pulses are > working. The numbers are wrong. It is almost 40 seconds before the reset > pulse occurs and the gate is staying on for about 4.4 seconds. I found > the problem after you pointed it out. > This was another error in the code given by the Mikroelektronika > timer calculator. The code from the calculator was void Interrupt1(). > Capitol I and the numeral 1. That is two problems in one line. It has to > be void interrupt 'somename'(void) and no prototype. I'll work on the > timing. That will be pretty easy. I sure learned a lot on this one. > Watch out for the calculator. It is not correct for XC8. > Thanks, > rich! > > On 7/23/2014 11:49 AM, Jan-Erik Soderholm wrote: >> Jan-Erik Soderholm wrote 2014-07-23 18:39: >> >>> Had to change "void interrupt()" to "void interrupt myisr()". >>> >>> "interrupt" is a function argument, not the name itself. >>> >> See also "5.9.1 Writing an Interrupt Service Routine" in the XC8 docs. >> >> "The function qualifier interrupt may be applied to a C function >> definition so that it will be executed once the interrupt occurs" >> >> And the example is clear on this: >> >> void interrupt tc_int(void) >> { >> if (TMR0IE && TMR0IF) { >> TMR0IF=3D0; >> ++tick_count; >> return; >> } >> // process other interrupt sources here, if required >> } >> >> >> Jan-Erik. > --=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 .