The problem I have is programming a synthesizer using hex commands. Now, the user will input a desired frequency down to 0.5mhz steps. So for example 13,051.5 MHz. Now that number needs to be divided by 50 to get the number that needs to be converted to hex to actually program the synth.
So 13,051.5 divided by 50 would be 261.03. However that number needs splitting so that the 261 can be converted to hex as a separate integer. The hex number for 261 is 105.
Then the decimal 0.03 needs turning into a fraction. So 0.03/1 * 1000/1000 = 30/1000
The numerator and denominator needs turning into a hex as well. So 30 would 1E in hex and 1000 would be 3E8.
Then these hex values need to be sent as;
Can anyone help me turn this into a code? Would be extremely helpful as this is confusing the hell out of me. Keep in mind the inputted frequency can be different in between 13,000MHz and 20,000MHz. Many thanks