LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-8451 SPI Read/Write MOSI

I have a USB-8451 that I am using for SPI communications. The USB-8451 is the master device, and I have no problem sending and recieving data. The problem is that I cannot send what I want to with the USB-8451. When I execute a read command for 16 bit data, the USB-8451 sends 0x0300. I need to send certain commands over SPI in order to get the correct response; ie - send 0x1000, 0x2000, 0x3000, etc. I have not found a way to do this, and it is very critical that I am able to for this project to work correctly. Any suggestions?  
0 Kudos
Message 1 of 6
(3,569 Views)
Have you gone through this thread that explains 16 bit data transfer?
0 Kudos
Message 2 of 6
(3,550 Views)
It's not an issue of communicating over SPI, the data bit size, or getting data back. I am using the USB-8451 as the SPI master. I want it to write a 4 bit opcode (0x1-0xF) and complete the 16 bit transfer with zeroes (i.e. 0xB000). It seems that the EEPROM on the USB-8451 requires OpCodes (0x3 or 0x4). It sends over the MOSI line 0x0300 or 0x0400 (up to 0x0BFF). I don't want it to send that data over. I want to format the 16 bit data that it sends on its MOSI line as stated above. The opcodes signify a different operation and returned result from the Slave device, so it is critical that it works this way.  
0 Kudos
Message 3 of 6
(3,547 Views)

Hello Johu,

 

The SPI Read Write vi has a data write input which takes in an array of bytes.  If you want to ONLY read 16 bit, you have to put an array of 2 bytes which are 0.  Since SPI is a full duplex protocol, it will send 0x00 0x00 and receive 16 bits at the same time.  

 

Usually, you send a command before reading.  So, you would send a total of three bytes, the first one being your command.  The first byte returned would not contain any data, since your device is reading the command.  The 2 last bytes would contain your data.  So:

 

Bytes Sent         Bytes Read

CMD                           0 (or should be 0)

0                                 Data1

0                                 Data2

 

You can download these test panels and try to using them to send your commands and read your data.  

 

Please let me know if any of this is not clear or if you need more help with this.  Have a great day.   

 

O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 4 of 6
(3,531 Views)
Can you send me the VI for Labview v8.0?
0 Kudos
Message 5 of 6
(3,520 Views)

Hello Johu,

 

You only need the LV 8.5 runtime to run the executable.  

 

I attached the 8.0 version of the VI.  Let me know if you have any questions. 

O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 6 of 6
(3,502 Views)