UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
8,064 Views
Registered: ‎09-14-2008

My SPI-Module refuses to work

I want to use the SPI-module in my running microblaze but it dont works. If i use the loopback-mode it works.

 

I use it in polled mode 

If i measure the voltage on the pin i got those values:

 

MOSI   0,2V

MISO   0,3V

SCK   0V (I also checked this pin by the osci. --> no oscillation)

SS    0V

 

Hopefully anybody can help me.

 

Here is my ucf-file:

#### Module SPI constraints
Net xps_spi_0_MOSI_pin LOC = H24;
Net xps_spi_0_MISO_pin LOC = J24;
Net xps_spi_0_SCK_pin LOC = M20;
Net xps_spi_0_SS_pin<0> LOC = M19;
Net xps_spi_0_SS_pin<1> LOC = G24;
Net xps_spi_0_SS_pin<2> LOC = G25;

 

Here is my MHS:

BEGIN xps_spi
 PARAMETER INSTANCE = xps_spi_0
 PARAMETER HW_VER = 2.00.b
 PARAMETER C_BASEADDR = 0x8d200000
 PARAMETER C_HIGHADDR = 0x8d20007f
 PARAMETER C_NUM_SS_BITS = 3
 BUS_INTERFACE SPLB = mb_plb
 PORT IP2INTC_Irpt = xps_spi_0_IP2INTC_Irpt
 PORT SCK = xps_spi_0_SCK
 PORT MISO = xps_spi_0_MISO
 PORT MOSI = xps_spi_0_MOSI
 PORT SS = xps_spi_0_SS
END


Here my MSS:


BEGIN DRIVER
 PARAMETER DRIVER_NAME = spi
 PARAMETER DRIVER_VER = 2.00.a
 PARAMETER HW_INSTANCE = xps_spi_0
END


And here is my c-code:

 

// SPI initialisieren

if (XST_SUCCESS != XSpi_Initialize ( &SPI_1, XPAR_XPS_SPI_0_DEVICE_ID ))

{return XFALSE;} //Fehlerbehandlung für nicht richtig init. SPI

// Selbstest der SPI-Schnittstelle

if (XST_SUCCESS != XSpi_SelfTest ( &SPI_1 ))

{return XFALSE;} //Fehlerbehandlung falls Selbsttest nicht richtig durchgeführt worden konnte.

// Optionen setzen

if (XST_SUCCESS != XSpi_SetOptions (&SPI_1, XSP_MASTER_OPTION | XSP_MANUAL_SSELECT_OPTION) ) // XSP_LOOPBACK_OPTION

{return XFALSE;} //Fehlerbehandlung falls Optionen setzen nicht richtig durchgeführt werden konnte

// Master-Transaktionen zulassen

XSpi_mEnable (&SPI_1);

// Disable alle INT

//XSpi_mIntrDisable ( &SPI_1, 0x7F );

u32 not_desired_slave = 6;

XSpi_mSetSlaveSelectReg ( &SPI_1, not_desired_slave ) ;

 

// SPI_1 starten

if (XST_SUCCESS != XSpi_Start ( &SPI_1 ) )

{print("\r\nFehler beim Starten von SPI.");}

// Disable Global SPI INT

XSpi_mIntrGlobalDisable(&SPI_1);

 

and in the function main():

u32 count;

for (count = 0; count < SPI_GROESSE; count++)

{

SendBuf[count] = count;

RecvBuf[count] = 0;

}

 

while (1)

{

 

XSpi_Transfer (&SPI_1,SendBuf,RecvBuf, (unsigned int)SPI_GROESSE) ;

// Status = XSpi_Transfer (&SPI_1,SendBuf,SendBuf, (unsigned int)SPI_GROESSE) ;

while (Status != XST_DEVICE_BUSY)

{;}


}

thanks for the answers

 

M.Rapp

0 Kudos
6 Replies
Contributor
Contributor
8,024 Views
Registered: ‎09-14-2008

Re: My SPI-Module refuses to work

Good Afternoon

 

I know its weekend but i allways think about it. 

 

OK. I found some solutions for my problems.

There was a ground-problem.

 

But there is another problem.

If i activate the loop-back function i can measure the clock.

But if i deactivate the loop-back function there is no clock to measure.

 

Can anybody help me?

 

Wish You a nice weekend

 

Greetings

 

M.Rapp

0 Kudos
Observer ck84
Observer
7,750 Views
Registered: ‎10-13-2008

Re: My SPI-Module refuses to work

Your problem is that you didn't start your SPI core. You only enabled it. So it is capable of transfering data but it didn't get the green light to go ahead and do so.
0 Kudos
Contributor
Contributor
7,734 Views
Registered: ‎09-14-2008

Re: My SPI-Module refuses to work

Hi ck84

thanks for answering me.

in the code you can find those lines:

 

// SPI_1 starten

if (XST_SUCCESS != XSpi_Start ( &SPI_1 ) )

{print("\r\nFehler beim Starten von SPI.");}

 

So i think i started the spi-core correctly, or?

 

But there is still this problem:

If i activate the loop-back function i can measure the clock.

But if i deactivate the loop-back function there is no clock to measure.

 

Greetings

 

M.Rapp

0 Kudos
Newbie osti123
Newbie
7,516 Views
Registered: ‎12-07-2008

Re: My SPI-Module refuses to work

Hi,

 

did you solve the problem? I have the same problem and found up to now no solution.

 

Regards.

0 Kudos
Contributor
Contributor
7,502 Views
Registered: ‎09-14-2008

Re: My SPI-Module refuses to work

No. I did not found any solution.

 

Perhaps an Xilinx Employee will help us?

 

Greetings

 

Rapp

0 Kudos
Newbie osti123
Newbie
7,299 Views
Registered: ‎12-07-2008

Re: My SPI-Module refuses to work

Hi, i have the solution:

 

use instead of

XSpi_mSetSlaveSelectReg ( &SPI_1, not_desired_slave ) ;

 

the command

XSpi_SetSlaveSelect(&SPI,  1); where 1 is the mask for the desired Slave Select.

 

After this change my SPI Master works well.

(Reason: With debugger you can see that every time you use mSetSlaveSelectReg there is slave_select_mask and slave_select at the same value and this is only possible for slave mode - don´t ask why :smileywink:

 

Regards!

0 Kudos