From 60f063265e8e2aa34ba419255f1ae41fe2596417 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Thu, 10 Jun 2021 19:21:01 -0400 Subject: conversion of decimal numbers to binary is done in when registers are calculated --- freq2lmx2487settings.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/freq2lmx2487settings.lua b/freq2lmx2487settings.lua index c3031e9..1de1cad 100644 --- a/freq2lmx2487settings.lua +++ b/freq2lmx2487settings.lua @@ -16,18 +16,7 @@ function freq2regestersValues(freq) local RF_FD = 4000000 --magic number local RF_FN = math.floor( (frac * RF_FD) + 0.5) - local bRF_N=toBits(RF_N) - local bRF_FN=toBits(RF_FN) - local bRF_FD=toBits(RF_FD) - pad2NumBitsInPlace(bRF_N, 11) - pad2NumBitsInPlace(bRF_FN, 22) - pad2NumBitsInPlace(bRF_FD, 22) - - -- print("bRF_N = "..bin2string(bRF_N, " ")) - -- print("bRF_FN = "..bin2string(bRF_FN, " ")) - -- print("bRF_FD = "..bin2string(bRF_FD, " ")) - - return freq, bRF_N, bRF_FN, bRF_FD + return freq, RF_N, RF_FN, RF_FD end ------ INITIAL SETTINGS (send to chip)------- @@ -63,7 +52,18 @@ end --------- SLICE AND REPLACE ------------ function FreqToSettings(freq, old_settings) --create table with new values of R0, R1, and R5 local settings= copySettings(old_settings) - local freq, bRF_N, bRF_FN, bRF_FD = freq2regestersValues(freq) + local freq, RF_N, RF_FN, RF_FD = freq2regestersValues(freq) + + local bRF_N=toBits(RF_N) + local bRF_FN=toBits(RF_FN) + local bRF_FD=toBits(RF_FD) + pad2NumBitsInPlace(bRF_N, 11) + pad2NumBitsInPlace(bRF_FN, 22) + pad2NumBitsInPlace(bRF_FD, 22) + + -- print("bRF_N = "..bin2string(bRF_N, " ")) + -- print("bRF_FN = "..bin2string(bRF_FN, " ")) + -- print("bRF_FD = "..bin2string(bRF_FD, " ")) --print(bin2string(settings["R0"], " ")) settings["R0"]=tableReplace(settings["R0"], bRF_N, 14, 24) -- cgit v1.2.3