Commit 94555e16 authored by Matthieu Cattin's avatar Matthieu Cattin

test39: Fix hex2signed function, prints more info.

parent 184e2ba9
......@@ -76,9 +76,9 @@ def fmc_adc_init(spec, fmc):
# Converts two's complement hex to signed
def hex2signed(value):
if(value & 0x8000):
return -((~value & 0xFFFC) + 1)
return -((~value & 0xFFFF) + 1)
else:
return (value & 0xFFFC)
return (value & 0xFFFF)
# Converts digital value to volts
def digital2volt(value, full_scale, nb_bit):
......@@ -370,12 +370,13 @@ def main (default_directory='.'):
# Apply a DC offset
##################################################
dc_offset = 0xA000
print("\nSet dc offset to: 0x%08X"%(dc_offset))
fmc.set_dc_offset_corrected(1, IN_RANGE, dc_offset, print_value=True)
##################################################
# Acquire channel 1
##################################################
print "\nAcquiring channel 1"
print "Acquiring channel 1"
# Configure analogue input
fmc.set_input_range(1, IN_RANGE)
fmc.set_input_term(1, IN_TERM)
......@@ -406,6 +407,8 @@ def main (default_directory='.'):
##################################################
g = adc_corr_data[IN_RANGE]['gain'][0]
o = adc_corr_data[IN_RANGE]['offset'][0]
#g = 0x8000
#o = 0
print "\nApply ADC offset correction: gain=0x%04X, offset=0x%04X" %(g, o)
fmc.set_adc_gain_offset_corr(1, g, o)
......@@ -414,7 +417,7 @@ def main (default_directory='.'):
##################################################
# Acquire channel 1
##################################################
print "\nAcquiring channel 1"
print "Acquiring channel 1"
# Perform an acquisition
acq_data, trig_timetag = acq_channels(fmc, carrier, ADC_FS[IN_RANGE], ACQ_PAUSE)
channel_data = acq_data[0::4]
......@@ -434,6 +437,7 @@ def main (default_directory='.'):
# Set saturation
##################################################
sat_thres = 10000
print("\nSet saturation to: 0x%08X"%(sat_thres))
fmc.fmc_adc_csr.set_field('CH1_SAT', 'VAL', sat_thres)
fmc.fmc_adc_csr.set_field('CH2_SAT', 'VAL', sat_thres)
fmc.fmc_adc_csr.set_field('CH3_SAT', 'VAL', sat_thres)
......@@ -442,7 +446,7 @@ def main (default_directory='.'):
##################################################
# Acquire channel 1
##################################################
print "\nAcquiring channel 1"
print "Acquiring channel 1"
# Perform an acquisition
acq_data, trig_timetag = acq_channels(fmc, carrier, ADC_FS[IN_RANGE], ACQ_PAUSE)
channel_data = acq_data[0::4]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment