Thank you everybody for the suggestions. 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. So I thought I couldn't use a second timer to generate a second wave without reducing the frequency range. In the pic main routine I am not doing anything urgent, just driving a 7 segment display. 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. Cheers. On 16 February 2010 21:49, ivp wrote: > Cristiano, > > > I have got the feeling it is not good spending most of the CPU time > > handling interrupt routines > > Where the PIC is spending its time is largely irrelevant. An interrupt is > just another routine > > > Signals change from 0V to 5V, and frequency from 0Hz to 3KHz > > > If anybody has a good idea, I would be very grateful. > > In this project of mine for a sensor exciter, the PIC generates low > frequency 6-bit PWM using a timer. Frequency and duty are settable > with pots. There is plenty of processing time left, which is going to be > used for other controls and outputs > > http://www.piclist.com/techref/microchip/HV_PWM_Proto.htm > > At your highest frequency, 3kHz, that means at least 6,000 interrupts > per second, which is not a lot for a fast PIC. That would be 1666.66 > instruction cycles at 40MHz > > What you need to decide is the resolution and accuracy you need for > these waves. If you want a 3000Hz and 2999Hz wave at the same > time then obviously the timer will have to interrupt more frequently > > How are you handling the USB ? I'm sure it could be processed under > interrupt too, without affecting the waves > > wbr > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist