Round radio calibration value instead of truncating
authorKeith Packard <keithp@keithp.com>
Fri, 12 Mar 2010 18:35:12 +0000 (10:35 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 12 Mar 2010 18:35:12 +0000 (10:35 -0800)
The radio calibration function in the bring-up code was truncating the
radio calibration value which caused the resulting frequency to
always measure above the target frequency, instead of trying to get as
close as possible. This change will result in a closer frequency
match, but may sometimes be below the target frequency.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-bringup/turnon_teledongle

index 1786f25..97c1e41 100755 (executable)
@@ -19,7 +19,7 @@ sleep 5
 echo -n "Generating RF carrier.  Please enter measured frequency: "
 read FREQ
 
-CAL_VALUE=`nickle -e "ceil(434.55 / $FREQ * 1186611)"`
+CAL_VALUE=`nickle -e "floor(434.55 / $FREQ * 1186611 + 0.5)"`
 
 echo "Programming flash with cal value " $CAL_VALUE
 ao-load --cal $CAL_VALUE /usr/share/altos/teledongle-v0.2.ihx $SERIAL