Question

Posted (edited)

Hi all,

I am working on SPI transceiver with AD2 in master mode. I am using python sample codes provided. transmitting is working fine but in receiving i am able to get the signals on wire but not to the variable in python

rgwRX = (c_uint16*1)()
while True:
    dwf.FDwfDigitalSpiSelect(hdwf, c_int(4), c_int(0))
    dwf.FDwfDigitalSpiRead16(hdwf, c_int(2), c_int(24),rgwRX, c_int(len(rgwRX)))
    dwf.FDwfDigitalSpiSelect(hdwf, c_int(4), c_int(1))
    print rgwRX[0]

I am getting only '0's

corresponding signal while receiving tapped on CRO is attached and it is proper

TEK02559.PNG

 

but when i try it using Waveforms software it works but i see same signal on wire

TEK00001.PNG.4da7b71799e4a17f848e0823557ce57e.PNG

Edited by Lakshmi Tejas M A

Share this post


Link to post
Share on other sites

14 answers to this question

Recommended Posts

  • 0
Posted (edited)

Hi @attila

Thank you for the info on update and bug. 

  1. Also wanted to know there is transmit option in SPY mode?
  2. as you suggested the update of software i did but i see i can get some data but decoding wrong.

actual data to be received 1,2,3,4,1,2,3,4,.... but i am receiving 0x5557,0x555d,0x555f,0x5575,0x5557,0x555d,0x555f,0x5575...
i think decoding is wrong

      3. in the function dwf.FDwfDigitalSpiRead16(hdwf, c_int(2), c_int(24),rgwRX, c_int(len(rgwRX))), i need 12 bits to receive but i need to set 24 to get 12 clk pulses.

Edited by Lakshmi Tejas M A

Share this post


Link to post
Share on other sites
  • 0

Hi @Lakshmi Tejas M A

The FDwfDigitalSpi functions use the digital inputs only when a function with read is called, like: FDwfDigitalSpiWriteRead, FDwfDigitalSpiRead
The spy method, as in DigitalIn_Spi_Spy.py example can be used at the same time with FDwfDigitalSpiWrite functions, like here: 
Digital_Spi_Spy.py

Share this post


Link to post
Share on other sites
  • 0

Hi @attila

As you suggested the update of software i did but i see i can get some data but decoding wrong.

actual data to be received 1,2,3,4,1,2,3,4,.... but i am receiving 0x5557,0x555d,0x555f,0x5575,0x5557,0x555d,0x555f,0x5575...
i think decoding is wrong

the signal on the wires are proper

Share this post


Link to post
Share on other sites
  • 0

Hi @Lakshmi Tejas M A

Make sure the SPI mode, bit order, cBitPerWord for master and spy are the same...

>python Digital_Spi_Spy.py
DWF Version: b'3.8.8'
Opening first device
Configuring Digital In...
Configuring SPI master...
Configuring SPI spy...
Type data array to send and press enter, like: 1 2 3
1 2 3 4 5 6 7
Sending:  [1, 2, 3, 4, 5, 6, 7]
bits:57
spy mosi|miso :
0x1 | 0x1  0x2 | 0x2  0x3 | 0x3  0x4 | 0x4  0x5 | 0x5  0x6 | 0x6  0x7 | 0x7

Share this post


Link to post
Share on other sites
  • 0
3 hours ago, attila said:

Hi @Lakshmi Tejas M A

Make sure the SPI mode, bit order, cBitPerWord for master and spy are the same...

>python Digital_Spi_Spy.py
DWF Version: b'3.8.8'
Opening first device
Configuring Digital In...
Configuring SPI master...
Configuring SPI spy...
Type data array to send and press enter, like: 1 2 3
1 2 3 4 5 6 7
Sending:  [1, 2, 3, 4, 5, 6, 7]
bits:57
spy mosi|miso :
0x1 | 0x1  0x2 | 0x2  0x3 | 0x3  0x4 | 0x4  0x5 | 0x5  0x6 | 0x6  0x7 | 0x7

hi @attila

i was telling about Digital_Spi_Dual.py not Digital_Spi_Spy.py

Share this post


Link to post
Share on other sites
  • 0

Hi @Lakshmi Tejas M A

In the FDwfDigitalSpiWrite/Read functions the 2nd argument specifies the SPI mode:
cDQ: 0 =SISO, 1 =MOSI/MISO, 2 =dual, 4 =quad
DWFAPI BOOL FDwfDigitalSpiWrite(HDWF hdwf, int cDQ, int cBitPerWord, unsigned char *rgTX, int cTX);

Here you can see the output of the Digital_Spi_Dual.py captured with another device. It looks correct to me.

...
rgbTX = (c_ubyte*16)(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)

dwf.FDwfDigitalSpiSelect(hdwf, c_int(0), c_int(0)) # CS DIO-0 level 0
#                             cDQ dual  bits 8    data 0
dwf.FDwfDigitalSpiWrite(hdwf, c_int(2), c_int(8), rgbTX, c_int(len(rgbTX))) # write from array of 8bit(byte) elements in dual mode 8bit data lengths
dwf.FDwfDigitalSpiSelect(hdwf, c_int(0), c_int(1)) # CS DIO-0 level 1
...

image.thumb.png.3aa631c02e6ba2e03d8b324c1b647c3c.png

Share this post


Link to post
Share on other sites
  • 0
On 8/1/2018 at 10:36 AM, Lakshmi Tejas M A said:

Hi @attila

As you suggested the update of software i did but i see i can get some data but decoding wrong.

actual data to be received 1,2,3,4,1,2,3,4,.... but i am receiving 0x5557,0x555d,0x555f,0x5575,0x5557,0x555d,0x555f,0x5575...
i think decoding is wrong

the signal on the wires are proper

hi @attila

yes transmitting from the ad2 python is perfect. Receiving is the issue.

Share this post


Link to post
Share on other sites
  • 0
On 7/31/2018 at 7:36 PM, attila said:

Hi @Lakshmi Tejas M A

The FDwfDigitalSpi functions use the digital inputs only when a function with read is called, like: FDwfDigitalSpiWriteRead, FDwfDigitalSpiRead
The spy method, as in DigitalIn_Spi_Spy.py example can be used at the same time with FDwfDigitalSpiWrite functions, like here: 
Digital_Spi_Spy.py

hi @attila

i tried the code you gave digital_spi_spy.py , I am getting like this 
image.png.451de1006de3066df9804ed7e3762f34.png
i don't understand why ('Sending: ', [1, 2, 3]) is in MOSI and 0xFF in MISO.

 

Share this post


Link to post
Share on other sites
  • 0

Hi @Lakshmi Tejas M A

Did you connect anything to the MISO?

Connecting a wire from DIO 2 to 3 for loopback, it receives what it sends out:

DWF Version: b'3.8.9'
Opening first device
Configuring Digital In...
Configuring SPI master...
Configuring SPI spy...
Type data array to send and press enter, like: 1 2 3
1 2 3
Sending:  [1, 2, 3]
bits:25
spy mosi|miso :
0x1 | 0x1  0x2 | 0x2  0x3 | 0x3
Type data array to send and press enter, like: 1 2 3
1 2 3
Sending:  [1, 2, 3]
bits:25
spy mosi|miso :
0x1 | 0x1  0x2 | 0x2  0x3 | 0x3
Type data array to send and press enter, like: 1 2 3
1 2 3 4 3
Sending:  [1, 2, 3, 4, 3]
bits:41
spy mosi|miso :
0x1 | 0x1  0x2 | 0x2  0x3 | 0x3  0x4 | 0x4  0x3 | 0x3
Type data array to send and press enter, like: 1 2 3

 

Share this post


Link to post
Share on other sites
  • 0
13 hours ago, attila said:

Hi @Lakshmi Tejas M A

Did you connect anything to the MISO?

Connecting a wire from DIO 2 to 3 for loopback, it receives what it sends out:


DWF Version: b'3.8.9'
Opening first device
Configuring Digital In...
Configuring SPI master...
Configuring SPI spy...
Type data array to send and press enter, like: 1 2 3
1 2 3
Sending:  [1, 2, 3]
bits:25
spy mosi|miso :
0x1 | 0x1  0x2 | 0x2  0x3 | 0x3
Type data array to send and press enter, like: 1 2 3
1 2 3
Sending:  [1, 2, 3]
bits:25
spy mosi|miso :
0x1 | 0x1  0x2 | 0x2  0x3 | 0x3
Type data array to send and press enter, like: 1 2 3
1 2 3 4 3
Sending:  [1, 2, 3, 4, 3]
bits:41
spy mosi|miso :
0x1 | 0x1  0x2 | 0x2  0x3 | 0x3  0x4 | 0x4  0x3 | 0x3
Type data array to send and press enter, like: 1 2 3

 

@attila

Yes i have connected MISO and MOSI of a micro controller. i want to receive and transmit data with micro, making ad2 as a slave. I dont want to work in master mode
spi_Slave is able to receive but not sending. see if you can help me to transmit from ad2 in slave mode.

thank you

Share this post


Link to post
Share on other sites

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