PICdude wrote: > T2CON = 0x04; // T2ON, prescaler & postscaler = 1:1 > T2CON = 0x01; // adjust prescaler > PR2 = 0xB4; // w/pres.1:1, 0xB4 sets 125us scan rate. > TMR2IF = 0x00; > TMR2IE = 0x01; > ... > > Is there a reason for the second line? T2CON is set, then immediately > changed again? I figured I'd ask in case there's some errata I missed > where perhaps the prescaler is supposed to be set to 1:1 while > switching on T2, etc. Or maybe this is some C-specific workaround? > Or am I reading too far into what is really a typo? Microchip makes great chips, but their code generally sucks. Unless the data or errata documents say something about changing the prescaler from 1:1 only after the timer is on (and I'd be rather surprised if they do), then this is just a stupidity. The comments also don't tell you as much as they should. When you write this, you should document every bit. You should never set a collection of individual bits to a HEX number like this. Do something like this (from 16F876, may be different on your chip): T2CON = 0b00010101; //X------- unused //-0010--- postscaler 1:3 //-----1-- timer on //------01 prescaler 1:4 Now we can see that the second line actually turns the timer off in addition to changing the prescaler. I think it's pretty clear this code is just bad. Run away. You're better off writing your own than looking at this bugware. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist