Thanks for your responses. I tried writing a delay in C code, and the microcontroller doesn't seem efficient in the counting process. The microcontroller can increment a variable only 80 times in 1 msec. So that means that it takes 12.5 usec to increment a variable just one time. With a 3.57945 MHz crystal, a clock cycle is .279 usec. So incrementing a variable just one time takes 45 clock cycles. I know that C isn't as efficient as Assembly language, but I didn't expect it to be this inefficient. I understand now that delays are usually executed in Assembly code. What is the proper way to insert Assembly language code into a C program for PICC? I recall trying to do this once but having difficulty getting it to compile, so I gave up. My new code snippit is: void delay_1_msec (void) { count = 0; while (count<80) { count++; } } void delay_10_msec (void) { count_10_msec = 0; while (count_10_msec<10) { delay_1_msec(); // 10 delays of 1 msec each. count_10_msec++; } } void delay_1_sec (void) { count_1_sec = 0; while (count_1_sec<100) { delay_10_msec(); // 100 delays of 10 msec each. count_1_sec++; } } -- Jason Hsu http://www.jasonhsu.com/swrwatt.html http://www.jasonhsu.com/swrwatt-c.txt http://www.jasonhsu.com/swrwatt-asm.txt -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist