Reading 15-bit encoder and translating integer values to absolute position.
Timer 4 is connected to count incrementally between 0-32765 (the encoder is actually that precise)
Then for the fun of it the 15-bit value is shifted to form 16-bit value (to accommodate other encoder widths)
Whole turns are counted in timer 4 interrupt.
What I end up getting is two values, whole turns (counted in the interrupt) and reading the timer HW register I get the current encoder reading. Then according to those two values I make a floating point absolute value.
Floating point value is then translated to two integers just for printing the value on screen. True encoder value is stored on those two integers. I used FPU to do that, only takes a couple of FPU instructions. First the sign of float is checked and either a plus or minus sign is moved in a char and the float made positive. Then the integer part is taken and subtracted from the float using FPU instruction and then the decimal part is multiplied by 1000.0 using FPU instruction and again the integer part is taken using FPU