In SX Microcontrollers, SX/B Compiler and SX-Key Tool, wbahn wrote: The approach you are using has some serious delay. The delay is O(n). This may not be an issue for your application. If you need it to run faster, you can use an O(log(n)) algorithm. For 8 bits, you basically have the following steps (in pseudocode): Load Gray code value into REG REG = (REG) XOR (REG >> 4) (>> means right shift, shifting zeros into the left side) REG = (REG) XOR (REG >> 2) REG = (REG) XOR (REG >> 1) The value in REG is now the binary value. If you are working with 16 bits, you only need to add a line that shifts it 8 places. NOTE: I'm assuming you are using a reflected Gray code - but I figure that's a pretty safe bet since your approach is only valid for that same type of Gray code. HTH ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=146196#m146279 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)