On Sun, Feb 14, 2010 at 7:47 PM, Josh Koffman wrote: >> Why don't you look at Peter Hemsley's 12-bit code at piclist.com? >> >> D3 will always be 0 for your application, of course, so you could >> shorten it a bit once you go through the exercise of understanding it, >> and it's really not too bad for your application even as-is. > > I'm working through it now. I tried putting it in macro form but > something funny is happening. It's bedtime here, but tomorrow I'll put > the code inline and massage it until I get it to work. Then I'll worry > about macro-ing it. I hope it works on the 18F line. I had to change > his rlf to rlcf and his: > skpnc > goto mod0 > > to > > bnc mod0 Well, I believe my code substitution is alright, but I think I've found another problem. In the 16F processors it appears that the decf command doesn't effect the carry bit, but in the 18F chips it does. That's screwing up the logic as the routine is assuming C is unchanged and was last effected by an addwf. Here's a snippet: mod0 addwf _D0,f decf _D1,f ; skpc ; goto mod0 bnc mod0 The commented lines are the ones I substituted with the bnc. Maybe I should try reversing the order of the commands? Then the C bit would be last effected by the addwf? Josh -- A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. -Douglas Adams -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist