Well 2 isn't too hard. You can use the 2 compare registers set to trigger the CCP outputs and change the compare value in an interrupt routine - you will need to change the action on each interrupt (i.e. on each half cycle change from set output to clear and vice versa). This is documented in the the Capture/Compare/PWM section of the manual. This only uses one timer module - TMR1 and can result in perfect square waves with no jitter, you can easily do this with a 4MHz clock to get up to 1KHz outputs. The third output is harder, but can be achieved with the Timer 0 module set to overflow more frequently than 1mS - say every 256uS with a 4MHz clock. Now you can count overflows on interrupts to set and clear an ouput - but it will be jittery ! You can obtain an exact frequency by correcting the timer in the interrupt routine by adding a value to it - this needs some care as the timer stops for a while after it is updated and of course the read value is also out of date, but it can be made to work- Alternatively PIC's are so cheap you could use 2 ! The coding is up to you - I wish you luck ! Robin Abbott - robin.abbott@fored.co.uk ************************************************************************** * * Forest Electronic Developments * http://www.fored.co.uk * ************************************************************************** ----- Original Message ----- From: To: Sent: 08 November 1999 12:34 Subject: Digital frequency generation > > A challenge: > > How to generate in a single PIC (16F877) 3 square waves with different > frequencies? and more: all the 3 frequencies can assume any value from > 1Hz to 1000Hz (in 1Hz steps). > Preferentially I wish to see an routine/algorithm that allow me to write > 3 words (2 bytes each)that will setup the 3 frequencies. This is my > problem. > Remember: this pic has 3 timer that could be used for this purpose... > However I thinking it may be possible to use only one timer module (!?) > > If it isn't possible to make via software, I accept sugestions about any > IC that exists and can do the following task: -Receive in I2C format the > word (two bytes) that will setup an internal oscillator that will > generate one square wave with the same value (in Hz) of the received > word (two bytes), so my problem is solved: I may use 3 of this ICs. > If your can help me or know an ICs that work like this or similar, > tell me. > > > See you, > > Beto. > > > > > _________________________________________________________________________ > MailBR - O e-mail do Brasil -- http://www.mailbr.com.br > Estamos concorrendo ao IBEST - Servigos On-Line > Acesse http://ibest.mailbr.com.br e Vote!