On Fri, 17 Aug 2007 22:16:57 +0000, borinhos wrote:
> I've worked with assembly code for texas C5410 for 2 months and I'm
> learning some concepts of fixed point arithmetic.
> One of the things I've learned so far is that there is only intergers,
> so, if my dynamic range is +/- 1, I may represent it as (-32767 +
> 32768) or (8000 and 7FFF in hex). So, for example, for a sin function
> I have numbers between that values.
> So,If I want to this: x = 2*0,5 = 1. Since I have no fractional
> numbers, I would have to do something like:2*16384 = 32768.
> What if i actually want to do 2*16284(meaning 16284 not 0,5) = 32768,
> the result would be the same! Or even worse, what if I want to do
> 2*16384.26 = 32768,52???
> My question is probably a dumb question but I find out I dont know how
> to program fixed point DSP's. Can anyone help me?
> Thanks
> Boris
What you do is you _call_ the range from 0x8000 to 0x7fff -1 to 1 (-1 to
almost 1, actually). Then you select operations that support that
interpretation. Addition and subtraction don't change. The DSP chip
probably supports the 'right' kind of multiply -- dig for it, it's there.
Division has to be done carefully, but then it always does.
The only thing left is I/O operations, but if you're just passing it from
an ADC to a DAC with all appropriate bit-fondling in between then you
don't have to worry about what the ADC or DAC calls it, just what they do
with it.
--
Tim Wescott
Control systems and communications consulting
http://www.wescottdesign.com
Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott
Elsevier/Newnes,
http://www.wescottdesign.com/actfes/actfes.html