IVP clear.net.nz> writes: >=20 > Hi James, >=20 >=20 > I agree that interrupts and look-up tables could be used to simplify > the coding. There is some groundwork needed to generate the data > but after that it's fairly straightforward. Even without NCO (such as > the F84) the pins can be alternated with BSF/BCF at the end of > each interrupt half-cycle >=20 > So, you'd have an interrupt for when to reload the timer, one table > for the reloads, one for the sweep period, (the number of interrupts), > possibly one for the initial load but that could be done via a goto > and the DIP switch >=20 > If you choose a short interrupt period (eg 100us) you'll have finer > control at the Hz level but it does mean a lot of changes (big tables) >=20 This approach works fine, main limitation is resolution (Hz) that can be achieved. I implemented square wave generator in PIC, although in C. For the audio frequencies that might not be an issue, depending on you requirements. =20 Another approach which will likely provide a better resolution, is to use DDS (direct digital synthesis), but remove the whole "generate clean sine-wave" part. A good example is http://www.g4jnt.com/PIC_DDS.pdf, there was also discussion about DDS on PIClist. The project linked above is in assembler. =20 Sergey --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .