Cristiano, > The reason I am worried is because USB communication are handled > by interrupts too and if I set the timer to overflow too often in order to > obtain a square wave with the higher frequency, the application running > on the PC freezes, probably because the USB communications are not > getting enough attention by the PIC OK, in that case you give the USB priority. Process that at the cost of some possible jitter in the waves. Updating the state of four waves would be pretty quick, but better to delay that until USB is finished > I have never investigated PWMs. I have no idea what frequency range > and resolution I can obtain from them, but I think I will try this option The PWM example linked to was intended to show you an example of wave creation using a timer interrupt. I wrote that because the PIC's h/w PWM module is based on Timer2, and so the frequency range is linked to the speed of the PIC. The lowest frequency is the highest count that can be made with Timer2. If you look at the PWM Frequencies table in a PIC datasheet you'll see that, for example, 2.44kHz is the lowest at 40MHz. Reducing Fosc will lower the bottom-end frequency but will also lower processing speed. 100Hz PWM @ 10-bit resolution would mean an Fosc of only 400kHz. 1Hz would be 4kHz Fosc. However, there's no reason why you can't run a PIC with a variable oscillator to make one variable frequency wave You don't mention whether you want any duty cycle variation. If not, eg 50:50, then it's a simple accumulator addition, as Bob described. You'll just need to set aside a big enough accumulator for each output If you want a non-square/variable duty, that will be two accumulators. One for on time, one for off. Which is what I've done in my project, but counting timer rollovers rather than individual cycles (done by the timer h/w). This coarsens the resolution but simplifies management That approach is OK until you run out of timers. If you can understand what's happening in my PWM project, the frequency pot changes the re-load value for the timer ( => number of rollovers/sec) and the duty pot alters the on-off balance in the rollover counter. Execution of tasks - reading ADC and updating the LCD - is done cyclically, based on the interrupt number in the 1 - 64 sequence. I'm looking at adding a second output, but if it starts getting too messy I'll probably splash out 3 bucks for a second PIC. Damn the expense !!! ;-) So, I think forget the PWM module and use a timer. Manage the IRQ with USB having higher priority over the timer wbr -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist