> > What would be the best way to create a 5 second delay with a 16c56? It really depends if you need to do anything else during that delay time. If not then Sean's delay looping looks really good. PICS are quite helpful because every instruction's execution time is completely deterministic. If you need to do somthing else, then using the timer is your best bet. Be aware that the PIC's timer will have jitter if you write to the timer register. The upshot is that if you really want anything close to precise timing, it's best to simply let the timer overflow and count the overflows. Here's an example. A 10 Mhz 16F84 timer register will count 2.5 million ticks per second. We can use the prescaler to reduce this down to exactly 9765.625 tics per second be setting the prescaler to 256. Then if we watch just the overflow then we'll get 38.14 tics per second. Then all you need to do is count 190 overflows. This will give you a delay of 4.98073 seconds. There are two ways to count the overflows. You can use interrupts and update the count in the interrupt service routine. Or you can keep interrupts off and watch the overflow bit yourself, updating the count and clearing the overflow bit. In this case you must be sure that your routine checks the bit within two overflows (52 ms in this example) or you'll miss a tick. Lastly to get truly precise timing and keep the no write rule in place you need to change crystal speeds so that they evenly divide by powers of 2. For example by switching the crystal to 9.8304 Mhz you can divide evenly all the way up to 2^17 power. This means that you can use the natural clock divide by 4, overflow the counter, and prescale by 32, and get precisely 75 overflows per second. Count 375 of these (unfortunately requiring 9 bits) and get a 5.00000 second delay. Hope this helps, > > Scott > > P.S. Thanks for all the help on PORTA. About five minutes after I > sent the message I had about 500 people telling me what to do. Thank > god none of you said to give up on PICs. I am making the transition > from 68xx and 68xxx to the PICs and the road looks long and far. It really isn't. PICS work very well because they are simple. However that simplicity sometimes requires rethinking how you do things, just like in the PORTA example and the timer stuff here. One learns from experience things like writing to the timer register messes up the count... BAJ >