Lecture 33
Class Objectives Have a firm understanding of the software needed to be designed to operate the enhancedPwm module.

Hardware/Software System

Fixed point arithmetic

The fixed point representation of a decimal number is realized by moving the decimal point from its usual position, just after the least significant bit, to somewhere between the MSB and LSB. The position of the decimal point is given by the number of bits to the left and right of the decimal point. So a 6.10 fixed point format binary number has 6 integer bits and 10 fractional bits for a total of 16 bits.

Before we start, we need to understand the term index when applied to a binary string. The index of a bit is its position relative to the decimal point with the index of 0 being assigned to the bit immediatly to the left of the decimal point. The indexes increase to the left and decrease to the right, making the bit immediatly to the right of the decimal point have an index of -1.

The following example shows how to interpert fixed point values.
Interpert 0000 1001 0000 0000 as a 6.10 FPF number
In other words find the value of 0000 10.01 0000 0000 
The integer is 000010 = 210
The fraction is .0100000000 = 2-2 = 0.2510
When converting back and forth between FPF and decimal it is easier to move the FPF decimal point to the LSB bit position, converting the FPF value into a regular integer binary number first. This technique is illustrated in the following example.
Interpert 0000 0000 0000 1010 as a 6.10 FPF number
In other words find the value of 0000 00.00 0000 1010 

The easy-hard way to do this is:
The integer is 000000 = 010
The fraction is .0000001010 = 2-7 + 2-9 = 9.765625*10-3

The hard-easy way to do this is:
Let's call our final answer x.
x = 000000.0000001010 
Move the decimal point of the FPF right 10 bits by multiplying both sides by 210
x*210 = 0000000000001010. 

The right side is an integer value, 1010.  So now we have 
x*210 = 1010
Dividing both sides by 210 yields

x = 1010 / 210 = 9.765625*10-3

Direct Digital Synthesis

To be completed....