Hi, This is also really a [PIC]: question, but as this is PICLIST, I reckon = it's ok ;) Anyway, while I wait for my programmer kit to arrive = (acutally, while I wait for paypal to validate me..) I'm trying to = design a tone generator circuit (basically a PIC that can generate = musical notes). I've been considering the possiblities, just thought = I'd share my thoughts for people to criticise etc. Methods 1. Using a frequency synthisizer IC - perhaps controlling a 555 = *somehow* (minimal interrupt use - i.e. set some pins to change = frequency. I was thinking using 8 pins for A/D conversion..) 2. Using hardware PWM - not sure on this one, as there's "only" 1 = channel (16F877).. maybe to be combined with... 3. Using software PWM (interrupts). I want 3 or 4 channels, and I feel = this is relatively easy using this method: 20Mhz crystal, clock divider =3D 5MIPS, TMR0 overflows 19531.25 times = a second - 19.5KHz is way higher than the range I need (4.9Khz being = D#8, quite a high note :D) Some example code (pseudocode): --------- // play_note plays a *note* on channel *chan* // basically sets the timeout value for each pulse (measured in = interrupts) // data[] is a table of values, telling the number of interrupts to keep = the pulse high/low for. // example: C5 @ 523.25 Hz.. 19531.25/523.25 =3D 37.2 (say 37) play_note(chan,note) chandata[chan] =3D data[note] chantimer[chan] =3D chandata[chan] // on_tmr0_overflow occurs at ~19.5Khz // decrements timeouts, sees if it's time to switch pulse state on_tmr0_overflow for (each in chan)=20 dec chantimer[chan] if (chantimer[chan] =3D=3D 0) { chantimer[chan] =3D chandata[chan] invert PWM_output_pin[chan] } next chan (all PWM output pins are tied together as +ve for a speaker) Anyway, just checking if they're anything obvious I've missed out here = (probably is). Another bonus mystery question: What about other = waveforms? Is it possible to attach caps in a "dodgy" fashion to = "smooth out" the square wave, creating a sine-ish wave? And just for = fun, I want some bass/treble controls (I know it won't be that = effective, but it's fun :P).. just some rotary potentiometers combined = with caps? Thanks, Kieren P.S. On a slightly unrelated theme, I've designed a circuit for checking = the status of 36 pushbuttons with only 7 I/O pins. If anyone can beat = this (there's probably a magical IC for it), I'd be superhappy.. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.