digital to analog converter

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

digital to analog converter

Jump to solution
1,961 Views
ThomasH
Contributor II
Hi!
 
I´m  using the DAC on the mc9s12e64 the first time and I´m woundering about the both 8 bit left and right oriented data register DACD. What´s the advantage of this??
 
Thanks,
Thomas
Labels (1)
Tags (1)
0 Kudos
1 Solution
510 Views
SteveRussell
Contributor III

When trying to do computation rapidly on real-world quantities, it is often helpful to look at integers as fractions of a "full scale" value.  This has the nice feature that multiplication of two quantities less than 1 will always give a result less than 1.  So to scale a quantity, you just do a multiply and take the most significant bits.  No shifting involved, just word operations.

Its real easy in assembler, but a little awkward in C, so hiding it in some function written in assembly may be a good idea. 

It seems like a fractional arithmetic class in C++ would make this easy, but I'm not aware of one.  (I haven't had occasion to look.)

View solution in original post

0 Kudos
1 Reply
511 Views
SteveRussell
Contributor III

When trying to do computation rapidly on real-world quantities, it is often helpful to look at integers as fractions of a "full scale" value.  This has the nice feature that multiplication of two quantities less than 1 will always give a result less than 1.  So to scale a quantity, you just do a multiply and take the most significant bits.  No shifting involved, just word operations.

Its real easy in assembler, but a little awkward in C, so hiding it in some function written in assembly may be a good idea. 

It seems like a fractional arithmetic class in C++ would make this easy, but I'm not aware of one.  (I haven't had occasion to look.)

0 Kudos