On Fri, May 11, 2012 at 1:04 AM, Manu Abraham wrot= e: > On Fri, May 11, 2012 at 12:50 AM, Bob Ammerman wr= ote: >>> Hi, >>> >>> I have my config fuses thus with a 20MHz XTAL connected >>> >>> #pragma config FOSC =3D INTOSC_HS >>> #pragma config PWRT =3D OFF >>> #pragma config BOR =3D OFF >>> #pragma config MCLRE =3D ON >>> #pragma config PBADEN =3D OFF >>> #pragma config ICPRT =3D OFF >>> #pragma config LVP =3D OFF >>> #pragma config WDT =3D OFF >>> >>> and a simple snippet as follows .. >>> >>> void main() >>> { >>> OSCCON =3D 0x72; /* 8MHz INTOSC drives clock directly */ >>> OSCTUNE =3D 0x80; /* 31.25 kHz device clock derived from 8 MHz INTOSC *= / >>> >>> while (1) { >>> Nop(); // this took .2uS or 200nS >>> Delay10TCYx(120); // this took 481.2 uS >>> =A0 =A0 =A0 =A0} >>> } >>> >>> With the simulator trace, I am viewing the elapsed time for each >>> instruction. >>> >>> Prior to OSCCON setup to 0x72, OSCCON was defaulting to 0x00 implying >>> 1MHz INTOSC driven clock. >>> >>> The trace showed an elapsed time period of 0.2uS at 1MHz. Even after >>> OSCCON was set to 8MHz INTOSC clock, I still do see the elapsed Tcy >>> period as 0.2uS itself. >>> >>> Am I missing something ? >>> >>> Thanks, >>> Manu >> >> Yes, the simulator only shows the time period based on the clock rate *y= ou >> enter*. It does not know the current clock rate of the simulated chip. >> >> -- Bob Ammerman >> RAm =A0Systems > > > The Simulator is set for a 20MHz "Processor frequency" which is same as t= he > crystal frequency and the simulator window also shows that. > > You meant to change that "Processor frequency" ? I am a bit confused. The information here http://w3.id.tue.nl/fileadmin/id/objects/E-Atelier/doc/Tutorials/DELAY_FUNC= TIONS_18F4550.pdf with a 20MHx crystal, Delay10TCYx (60); // gives a delay of 10 x 60 x 1/12 =3D 600/12 =3D 50 us This would be 100uS in my case with Delay10TCYx (120) but I am actually getting a delay of 481uS (Delay10TCYx(120); // this took 481.2 uS) --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .