SUB-20 Slave Mode
Moderator: serg
-
- Posts: 11
- Joined: Wed Jul 07, 2010 4:06 pm
SUB-20 Slave Mode
Hi,
The hardware setup i am currently using is a SUB-20 in slave mode connected to a DSP board. The DSP is set up to run as an SPI master and the SUB-20 is running as an SPI slave. The software is being written using C#. Currently i am able to use the FIFO_Read function to receive a byte of information from the DSP. Depending on the byte received the SUB-20 then needs to return a certain amount of data. The master device is aware of the amount of data that should be received and has been programmed to clock this data through the SPI chain by sending dummy data. So far however i have not managed to get the DSP to receive the correct data back from the SUB-20. I am using the FIFO_Write function to send the data back however the values received are wrong. Has anyone else experienced any issues with running it in this way or know of any solutions. Cheers in advance.
Andy
The hardware setup i am currently using is a SUB-20 in slave mode connected to a DSP board. The DSP is set up to run as an SPI master and the SUB-20 is running as an SPI slave. The software is being written using C#. Currently i am able to use the FIFO_Read function to receive a byte of information from the DSP. Depending on the byte received the SUB-20 then needs to return a certain amount of data. The master device is aware of the amount of data that should be received and has been programmed to clock this data through the SPI chain by sending dummy data. So far however i have not managed to get the DSP to receive the correct data back from the SUB-20. I am using the FIFO_Write function to send the data back however the values received are wrong. Has anyone else experienced any issues with running it in this way or know of any solutions. Cheers in advance.
Andy
Re: SUB-20 Slave Mode
Hi Andy,
Could you try to use the subtool GUI app to reproduce the issue?
Regards
Could you try to use the subtool GUI app to reproduce the issue?
Regards
Re: SUB-20 Slave Mode
Hi,
You should also to be sure about the sequence of the read/write(s).
The SPI slave (as well as master) is sending and receiving data simultaneously. I mean while the bit is shifted out from master via MOSI the MISO is shifted in. So if your master shifts out 1 byte at the same time in shifts in 1 byte.
You should also to be sure about the sequence of the read/write(s).
The SPI slave (as well as master) is sending and receiving data simultaneously. I mean while the bit is shifted out from master via MOSI the MISO is shifted in. So if your master shifts out 1 byte at the same time in shifts in 1 byte.
-
- Posts: 11
- Joined: Wed Jul 07, 2010 4:06 pm
Re: SUB-20 Slave Mode
Current set up i am trying after the advice above is as follows:
Sub Tool:
When i try the equivalent in C# however it does not work:
Using the C# code the DSP reads a value of 2.
Hope that all makes sense.
Andy
Sub Tool:
- SPI Tab
Enable is Ticked
Slave is Ticked
Polarity is Rise
Phase is SmplSetup
FIFO Tab
SPI is ticked
Timeout is 1000
Read Byte Count is 1
When i try the equivalent in C# however it does not work:
Code: Select all
Sub20 dev = new Sub20();
dev.Open();
dev.LDC_Write("\f");
dev.SPI_SetConfig(Sub20.SpiEnable | Sub20.SpiSlave | Sub20.SpiCpolRise | Sub20.SpiSetupSmpl);
dev.FIFO_SetConfig(Sub20.FifoSelectSpi);
byte[] output = new byte[1];
output[0] = 5;
int x = 0;
dev.FIFO_Write(output, 1000, ref x);
Hope that all makes sense.
Andy
Re: SUB-20 Slave Mode
You've missed phase:
Sub Tool:
Phase is SmplSetup
Code:
Sub20.SpiSetupSmpl
-
- Posts: 11
- Joined: Wed Jul 07, 2010 4:06 pm
Re: SUB-20 Slave Mode
Phase has been included in the code snippet above and the list of values for the Sub-20 app.
Re: SUB-20 Slave Mode
I mean you have different phase configurations in SUB Tool and in your program.
-
- Posts: 11
- Joined: Wed Jul 07, 2010 4:06 pm
Re: SUB-20 Slave Mode
Thanks for pointing that one out. I am now able to send one byte of data to the DSP. The new issue i beleive is to do with how the SUB-20 clocks the data in its FIFO to the DSP.
The c# program i run first does the following:
Cheers
The c# program i run first does the following:
- Setup the Sub20 as slave as shown above with the new phase used
Create a byte array of size 2 (with values 10 and 20)
FIFO_Write(array, 1000, ref x) where x = 1
- Pull the SS Pin Low
Send two bytes of data via MOSI
Read two values received via MISO
PUll the SS Pin High
Cheers
Re: SUB-20 Slave Mode
Hi,
No, this is not the case. SUB-20 slave is active as long as SS is low.
I wonder, if you push 2 bytes into FIFO why x=1 ?
No, this is not the case. SUB-20 slave is active as long as SS is low.
I wonder, if you push 2 bytes into FIFO why x=1 ?
-
- Posts: 11
- Joined: Wed Jul 07, 2010 4:06 pm
Re: SUB-20 Slave Mode
Ah i assume from your comment that the "ref Description" value (i.e what i call x) in the FIFO_Read and FIFO_Write functions should be the number of bytes being sent and received. Cheers