Skip to content

Commit

Permalink
bug fix for the LoadCodeLoaderHexFile() function
Browse files Browse the repository at this point in the history
  • Loading branch information
ruck314 committed Nov 2, 2023
1 parent 0d8745f commit c7ae2a9
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions python/surf/devices/ti/_Lmx2594.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,19 @@ def addLinkVariable(name, description, offset, bitSize, mode, bitOffset=0, pollI
@self.command(description='Load the CodeLoader .HEX file',value='',)
def LoadCodeLoaderHexFile(arg):

self.DataBlock.set(value=0x2410,index=0, write=True) # MUXOUT_LD_SEL=readback

##################################################################
# For the most reliable programming, TI recommends this procedure:
##################################################################

# 1. Apply power to device.
reg = self.DataBlock.get(index=0, read=True)

# 2. Program RESET = 1 to reset registers.
self.DataBlock.set(value=(reg|0x2), index=0, write=True)
self.DataBlock.set(value=0x2412, index=0, write=True)

# 3. Program RESET = 0 to remove reset.
self.DataBlock.set(value=(reg&0xFFFD), index=0, write=True)
self.DataBlock.set(value=0x2410, index=0, write=True)

# 4. Program registers as shown in the register map in REVERSE order from highest to lowest.
with open(arg, 'r') as ifd:
Expand All @@ -250,15 +251,9 @@ def LoadCodeLoaderHexFile(arg):
# print( f'addr={addr}, data={hex(data)}' )
self.DataBlock.set(value=data, index=addr, write=True)

self.DataBlock.set(value=data, index=addr, write=True)

# 5. Wait 10 ms.
time.sleep(0.1)

# 6. Program register R0 one additional time with FCAL_EN = 1 to ensure that the VCO calibration runs from a stable state.
self.DataBlock.set(value=(data|0x8), index=0, write=True)

# Turn off the SYNC after the stable state
self.DataBlock.set(value=0x0000, index=0x22, write=True)
self.DataBlock.set(value=0x0780, index=0x24, write=True)

self.DataBlock.set(value=data&0xFFFB, index=addr, write=True)
time.sleep(0.1)

0 comments on commit c7ae2a9

Please sign in to comment.