Commit 66eb9d1f authored by Jan Pospisil's avatar Jan Pospisil

added fine delay control; added possibility to generate just set/reset pulse

parent 52532479
......@@ -19,7 +19,7 @@ class ConColors:
m = encoreio.Module.get_instance('fmc_fpg', 0)
WB_DEBUG = True
WB_DEBUG = False
###################################################################
## WishBone access overlay
......@@ -92,6 +92,10 @@ def SpiWrite(register, data):
def Ad9512Init():
# power down unused output (OUT2)
SpiWrite(0x3f, 0x03)
# fine delay
SpiWrite(0x34, 0x0) # use fine delay
delay = 2 # 0-31
SpiWrite(0x36, (delay&0x1f)<<1) # set fine delay
# select CLK1 input, power down CLK2 input
SpiWrite(0x45, 0x05)
# output frequency 200 MHz (divide by 2)
......@@ -183,7 +187,8 @@ def ClearMemory(channel, memory):
# channel: 1, 2, 0 (for both)
# pulse: 0, 1
def ConfigurePulse(channel, start, stop, pulse):
# which: 0 - both, 1 - set, 2 - reset
def ConfigurePulse(channel, start, stop, pulse, which = 0):
if channel == 1:
address = 'ch1_'
elif channel == 2:
......@@ -204,16 +209,18 @@ def ConfigurePulse(channel, start, stop, pulse):
pulse &= 1
position = start/32
shift = start%32
WbSetBitsMulti(address+'set_mem', ((1<<shift),), ((pulse<<shift),), start=position, to=position+1)
if which < 2:
position = start/32
shift = start%32
WbSetBitsMulti(address+'set_mem', ((1<<shift),), ((pulse<<shift),), start=position, to=position+1)
position = stop/32
shift = stop%32
WbSetBitsMulti(address+'res_mem', ((1<<shift),), ((pulse<<shift),), start=position, to=position+1)
if which != 1:
position = stop/32
shift = stop%32
WbSetBitsMulti(address+'res_mem', ((1<<shift),), ((pulse<<shift),), start=position, to=position+1)
def CreatePulse(channel, start, stop):
ConfigurePulse(channel, start, stop, 1)
def CreatePulse(channel, start, stop, which = 0):
ConfigurePulse(channel, start, stop, 1, which)
def DeletePulse(channel, start, stop):
ConfigurePulse(channel, start, stop, 0)
......@@ -253,7 +260,6 @@ def Control():
## Test functions
###################################################################
def Init():
WbWrite('control', 0)
SpiInit()
......@@ -266,27 +272,31 @@ def Init():
def TestPulse(channel = 1):
# configure channel
WbWrite('overflow', 17820)
WbWrite('trig_latency', 10)
WbWrite('trig_latency', 8)
CreatePulse(channel, 5, 105)
start = 5
length = 1
stop = start + length
CreatePulse(channel, start + 2*channel, stop + 2*channel)
# CreatePulse(channel, 2, 2, 1)
# CreatePulse(channel, 5, 10)
# CreatePulse(channel, 25, 30)
# CreatePulse(channel, 125, 130)
WbWrite('ch'+str(channel)+'_delay_set', 100)
WbWrite('ch'+str(channel)+'_delay_res', 200)
WbWrite('ch'+str(channel)+'_delay_set', 1)
WbWrite('ch'+str(channel)+'_delay_res', 100)
# start channel
channel -= 1
channel %= 2
WbSetBits('control', 0x4<<channel, 0x4<<channel) # set output enable
channel *= 2
WbSetBits('control', 0x30<<channel, 0x10<<channel) # set mode CONT.
Init()
Control()
Status()
TestPulse(1)
TestPulse(2)
Control()
Status()
\ No newline at end of file
Status()
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