In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote: Hi All; If your purpose is to generate a PWM sourced analog output, then why not use the "pulse density" modulation approach. Unfortunately I do not know the name of this algorithm, but it only needs interrupts at the update rate, regardless of the value to be generated. On top of that the code is consistently just 6 instructions (always) and is bordering on trivial. No thinking to do whatsoever. Assembler of course, but trivial to create a function (or SX/B command for that matter). The process is to continually add the desired DAC value to an accumulator, and set/clear the output bit depending on wheter the carry was set/cleared respectively: DAC: mov w,DACValue (of course could be a constant) add DACAccum,w sc clrb PortBit snc setb PortBit Simple as pie...... I use this a lot. Cheers, Peter (pjv) ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=366927#m366990 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)