Other Parts Discussed in Thread: USB2ANY
Dear Team,
I try to set register values by using own source code (e.g., C, C++, Python) instead of using TICS Pro GUI.
After checking this page, there is a way to write register values using python.
Here, I attached the excerpt of python code in above link and there are several questions.
# Write and Read numerator = 0xDEADBEEF packet1 = 0x260000 + ((numerator >> 16) & 0xFFFF) packet2 = 0x270000 + (numerator & 0xFFFF) buf = ctypes.c_buffer(3) #register length is three bytes for LMX2594 buf[0] = (packet1 >> 16) & 0xFF buf[1] = (packet1 >> 8) & 0xFF buf[2] = packet1 & 0xFF errCode = u2adll.u2aSPI_WriteAndRead(handle, 3, buf) if errCode < 0: raise Exception('failed to write first packet') buf[0] = (packet2 >> 16) & 0xFF buf[1] = (packet2 >> 8) & 0xFF buf[2] = packet2 & 0xFF errCode = u2adll.u2aSPI_WriteAndRead(handle, 3, buf) if errCode < 0: raise Exception('failed to write second packet') buf[0] = 0xEF buf[1] = 0x00 buf[2] = 0x00 errCode = u2adll.u2aSPI_WriteAndRead(handle, 3, buf) if errCode < 0: raise Exception('failed to read R111') rb_VCO_CAPCTRL = ord(buf[2]) # R111[7:0].
1. Objective of using packet 1 and packet 2
I wonder why using packet 1 and packet 2 before setting up register R111[7:0].
I just think defining the buffer size is sufficient like buf = ctypes.c_buffers(3).
Is it mandatory to set packet 1 and packet 2 before writing the several register values?
If so, is there any criterion to set up packet values?
2. Register name based programming method
In the example code, it seems register value is written based on register field name.
is there other method to write the register value based on register name e.g, R0=0x00251C similar to TICS Pro GUI?
3. buf array in example code
I expected buff array whose size is 3 means 3 bytes value and buf[0] is the address of the register and buf[1] & buf[2] are specific values.
However, buf[0] was configured to 'EF' in the above code when writing the R111 value,
'EF' is not the address value of R111 so I want to know the meaning of each buf array value.
4. Validation method
After writing the register values in python code, is there a way to verify the register values in TICS Pro GUI?
Regards,
Sung