On Mar 10, 2006, at 11:51 AM, pic wrote: > My C program for flashing leds is not working. > /* Light the LEDs */ > LATD += 1; > Both of your programs use this to 'toggle' the LEDs, but I'm not sure it's a good idea due to the usual problems with Read/Modify/write on PICs. Just because you wrote a 1 or 0 to a port pin doesn't mean that's what will be read back when you read the port... Try it with a shadow register... latd_shadow += 1; LATD = latd_shadow; > void delay (void) > { > for (i = 0; i < 10000; i++) > ; > } > Depending on compiler specifics, this might be a very short delay to pair to human perceptions. I have a "flame" simulator that changes the brightness of some LEDs with a 128 count inner PWM loop and a 50 count outer loop (so, approximately equivilent to a 6400 count single loop) that flickers at a reasonably realistic rate (several times per second, at least), and it has a lot more stuff in the inner loop than your code. I seem to recall that PICs at nominal frequency take 24 bits worth of count to get delays in the one-second range. (Hmm. That was implicit in your timer-based attempt. prescale of 32 on a a 16 bit counter is ~2million cycles per second.) I would hope your compiler does the delay loop in far less than 100 cycles, for a delay period of far less than 0.5 seconds... BillW -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist