At 10:12 AM 8/18/2004 -0500, you wrote: >Hello everyone, > > I'm looking to make a circuit that uses two analogue inputs to >drive a PWM. I am trying to make the frequency of the output anywhere from >10 KHz to 250 KHz based on a potentiometer. Also, the duty of the circuit >needs to have an approximate 10% duty, but needs to be able to vary, again, >based on a potentiometer. I would like to use a 16F87x for this, and in >assembly (or if someone could help me find a decent compiler for some other >language, that would be simpler). The 16F877 already has a hardware PWM, >and I plan to use that, but I'm confused on how to make variable frequency >and variable pulsewidth. > > > >Any suggestions about where to start, or some example codes would be >helpful. You are going to get pretty crummy resolution in the timebase (especially) at the top end of the frequency range, and in the on time. Read the midrange reference manual's description of PWM mode carefully to see what I mean. 250kHz means you have only 4usec for the entire PWM cycle, with 400nsec on time. If the machine cycle is 200nsec (16F with 20MHz crystal) then that's the best you can do. Why do you want to change the timebase? It's called PWM for a reason- normally you just fiddle with the duty cycle (Width of the on time pulse) and leave the timebase alone. Best regards, Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu