Commit dbefc491 authored by Jan Pospisil's avatar Jan Pospisil

improved status reporting, added debug register

parent f66860fa
...@@ -152,9 +152,9 @@ def Ad9512Init(): ...@@ -152,9 +152,9 @@ def Ad9512Init():
# power down unused output (OUT2) # power down unused output (OUT2)
SpiWrite(0x3f, 0x03) SpiWrite(0x3f, 0x03)
# fine delay # fine delay
SpiWrite(0x34, 0x0) # use fine delay # SpiWrite(0x34, 0x0) # use fine delay
delay = 1 # 0-31 # delay = 1 # 0-31
SpiWrite(0x36, (delay&0x1f)<<1) # set fine delay # SpiWrite(0x36, (delay&0x1f)<<1) # set fine delay
# select CLK1 input, power down CLK2 input # select CLK1 input, power down CLK2 input
SpiWrite(0x45, 0x05) SpiWrite(0x45, 0x05)
# output frequency 200 MHz (divide by 2) # output frequency 200 MHz (divide by 2)
...@@ -285,12 +285,24 @@ def DeletePulse(channel, start, stop): ...@@ -285,12 +285,24 @@ def DeletePulse(channel, start, stop):
ConfigurePulse(channel, start, stop, 0) ConfigurePulse(channel, start, stop, 0)
def PrintBit(value, bit, label, ifSet, ifNotSet): def PrintBit(value, bit, label, ifSet, ifNotSet):
print(' '+'['+str(bit)+']'+label+':') print(' '+'['+str(bit)+'] '+label+':')
if value & (1<<bit): if value & (1<<bit):
print(ConColors.GREEN+' 1: '+ifSet+ConColors.NONE) print(ConColors.GREEN+' 1: '+ifSet+ConColors.NONE)
else: else:
print(ConColors.RED+' 0: '+ifNotSet+ConColors.NONE) print(ConColors.RED+' 0: '+ifNotSet+ConColors.NONE)
def PrintBits(value, bitFrom, bitTo, label, descriptions):
print(' '+'['+str(bitTo)+':'+str(bitFrom)+'] '+label+':')
value &= (1<<bitTo+1)-1
value >>= bitFrom
if value > len(descriptions)-1:
color = ConColors.RED
description = '<unknown>'
else:
color = ConColors.YELLOW
description = descriptions[value]
print(color+' '+str(value)+': '+description+ConColors.NONE)
def Status(): def Status():
print('Status register:') print('Status register:')
status = WbRead('status') status = WbRead('status')
...@@ -307,11 +319,12 @@ def Status(): ...@@ -307,11 +319,12 @@ def Status():
def Control(): def Control():
print('Control register: ') print('Control register: ')
control = WbRead('control') control = WbRead('control')
# PrintBits(control, 0, 1, 'Clock selection', ('external clock', 'FPGA LOOP', 'onboard VCXO')) # not implemented
PrintBit(control, 0, 'Clock mux', 'VCXO', 'FPGA LOOP') PrintBit(control, 0, 'Clock mux', 'VCXO', 'FPGA LOOP')
PrintBit(control, 2, 'Channel 1 output', 'enabled', 'disabled') PrintBit(control, 2, 'Channel 1 output', 'enabled', 'disabled')
PrintBit(control, 3, 'Channel 2 output', 'enabled', 'disabled') PrintBit(control, 3, 'Channel 2 output', 'enabled', 'disabled')
PrintBit(control, 4, 'Channel 1 mode', 'continuous', 'stop/one-shot') PrintBits(control, 4, 5, 'Channel 1 mode', ('stopped', 'continuous', 'one-shot'))
PrintBit(control, 6, 'Channel 2 mode', 'continuous', 'stop/one-shot') PrintBits(control, 6, 7, 'Channel 2 mode', ('stopped', 'continuous', 'one-shot'))
PrintBit(control, 8, 'LEDs', 'blinking', 'normal operation') PrintBit(control, 8, 'LEDs', 'blinking', 'normal operation')
PrintBit(control, 9, 'AD9512', 'in reset', 'running') PrintBit(control, 9, 'AD9512', 'in reset', 'running')
...@@ -337,6 +350,12 @@ def Stop(channel): ...@@ -337,6 +350,12 @@ def Stop(channel):
channel *= 2 channel *= 2
WbSetBits('control', 0x30<<channel, 0) # set mode STOP WbSetBits('control', 0x30<<channel, 0) # set mode STOP
def Debug():
print('Debug:')
debug = WbRead('debug')
PrintBits(debug, 0, 2, "CH1 FSM state", ("Stop", "WaitForTrigger", "Generating", "Outputting", "WaitForEnd"))
PrintBits(debug, 3, 5, "CH2 FSM state", ("Stop", "WaitForTrigger", "Generating", "Outputting", "WaitForEnd"))
################################################################### ###################################################################
## Test functions ## Test functions
################################################################### ###################################################################
...@@ -390,6 +409,7 @@ TestPulse(1) ...@@ -390,6 +409,7 @@ TestPulse(1)
# TestPulse(2) # TestPulse(2)
Control() Control()
Status() Status()
Debug()
################################################################### ###################################################################
## debug ending ## debug ending
......
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