Gordon, You can do this with a 1-bit output direct-digital synthesis technique. Given the following variables: unsigned long increment_value; unsigned long phase_accumulator; for (some number of iterations) { phase_accumulator += increment_value; // copy hi bit of phase_accumulator to output pin // code could look something like: movf output_port,W ; get existing port bit andlw ~(1 << output_bit) ; turn off current value btfsc phase_accumulator; ; is high bit on? iorlw 1 << output_bit ; yes: turn the bit on movwf output_port ; send it back to the hardware } The output frequency is directly proportional to 'increment_value'. Bob Ammerman RAm Systems ----- Original Message ----- From: "Gordon Varney" To: Sent: Wednesday, June 05, 2002 4:37 PM Subject: [PIC]: incrementing in steps > I need a pin to clock out a square wave at 800Hz. Simple, just set pin high for 625us, set pin low for 625us, and > repeat. > > Now I need to increment the clock frequency by 50Hz, do some work and increment by 50Hz again, continue incrementing > until complete. The step duration in a time period is not a constant. What is the best method to incrementing the > frequency by 50Hz. > > (Note: I am using a combination of Assembly and the CCS compiler for this program.) > > Gordon Varney > www.iamnee.com > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu