Jump to content
  • 0

DD SPI Python SDK Example


Alejandro-Dev

Question

From the example Digital_Spi.py I can get the following to work sending and receiving in the DD with a loopback cable:

rgbTX = (c_ubyte*10)(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

rgbRX = (c_ubyte*10)()

rgdw = c_uint32()



dwf.FDwfDigitalSpiSelect(hdwf, c_int(0), c_int(0)) # CS DIO-0 low

dwf.FDwfDigitalSpiWriteRead(hdwf, c_int(1), c_int(8), rgbTX, c_int(len(rgbTX)), rgbRX, c_int(len(rgbRX))) # write to MOSI and read from MISO

print("TX: "+str(numpy.fromiter(rgbTX, dtype=numpy.uint8)))

print("RX: "+str(numpy.fromiter(rgbRX, dtype=numpy.uint8)))


But I cannot get the same result using the individual write and read functions, like this:

 

dwf.FDwfDigitalSpiWrite(hdwf, c_int(1), c_int(8), rgbTX, c_int(len(rgbTX)))  # write array of 8 bit (byte) length elements
dwf.FDwfDigitalSpiRead(hdwf, c_int(1), c_int(8), rgbRX, c_int(len(rgbRX)))  # read array of 8 bit (byte) length elements
print("TX: "+str(numpy.fromiter(rgbTX, dtype=numpy.uint8)))
print("RX: "+str(numpy.fromiter(rgbRX, dtype=numpy.uint8)))

 

Why is that?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...