I have a 10 bit number "N" which I wish to scale by a factor of 0 to 1. The 0 to 1 scale factor is an 8 bit number, call it H
Thus I'd like to calc:
Value = (N*H)/250 or N*(H/250) H/250 thus is a 0-1 scale factor
I''d like the final result to be accurate to 10 bits, but N*H is 18 bits, thus I'd need an 18 bit mul & divide routine. I don't want to scale down N & throw away its 10 bit resolution. In some cases N willl be small, say a value of 11. In others N=1000. I don't want to throw away the 8 bit resolution of H either.
So I have (10bits*8bits)/8bits=10 bits
Using the Atmel assembly 16 bit mul & divide routines. any ideas? This problem appears simple, but turns out to be perplexing if I want the code to be simple