cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sha@hys
Explorer
Explorer
9,235 Views
Registered: ‎05-31-2015

XSpi_transfer not returning

Hi,

 

I am using XC6SLX45 fpga and has configured microblaze to work on. I am using xilinx sdk for programming in C. From Xilinx examples I made a program for my XPS_SPI core. I have used print statements to monitor the program progress step by step. I was able to see that XSpi_transfer function dont return at all and program is staying there. below given is my program.

 

#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include <xspi.h>
#include <xspi_l.h>
//#include <xspi.h>
//#include <xspi_i.h>

#define SPI_DEVICE_ID XPAR_XPS_SPI_0_DEVICE_ID
#define SPI_SELECT 0x01


int SpiSelfTestExample(u16 DeviceId);

XSpi Spi;
volatile int TransferInProgress;
Xuint8 *SendBufPrt;
Xuint8 outBuffer[4] = {0x00, 0xAA, 0xFF, 0xAA};
int i=0;
void print(char *str);

int main()
{
init_platform();

while(i<10)
{
print("Hello World Shalini\n\r");
i++;

}

int Status;


Status = SpiSelfTestExample(SPI_DEVICE_ID);
if (Status != XST_SUCCESS) {
print("\nfailed");
}

else
{print("\nSucess initialise");}


Status = XSpi_Transfer(&Spi, outBuffer, NULL, 2);
XSpi_Stop(&Spi);
print("\nspi stopped");
switch(Status)
{
case XST_SUCCESS:
print("Status: \nSuccess");
break;
case XST_DEVICE_IS_STOPPED:
print("Status: Device stopped\n\r");
break;
case XST_DEVICE_BUSY:
print("Status: Device busy\n\r");
break;
case XST_SPI_NO_SLAVE:
print("Status: Device no slave\n\r");
break;
default:
print("\nnot transferred");
}

while (TransferInProgress)
{print("\nTransferring");}
return 0;
}

int SpiSelfTestExample(u16 DeviceId)
{
print("Entered the function");

int Status;
XSpi_Config *ConfigPtr; /* Pointer to Configuration data */

/*
* Initialize the SPI driver so that it is ready to use.
*/
ConfigPtr = XSpi_LookupConfig(DeviceId);
if (ConfigPtr == NULL) {
return XST_DEVICE_NOT_FOUND;
print("\nDevice not found");
}
else
print("\nThe device found");

Status = XSpi_CfgInitialize(&Spi, ConfigPtr,
ConfigPtr->BaseAddress);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
print("\nDevice not configured");

}
else
print("\nDevice configured");

/*
* Perform a self-test to ensure that the hardware was built correctly
*/
Status = XSpi_SetOptions(&Spi, XSP_MASTER_OPTION);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
print("\nSPI not set as master");
}
else
{print("\nSPI set as master");}

Status = XSpi_SetSlaveSelect(&Spi, SPI_SELECT);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
print("Slave not selected");
}
else
{print("Slave selected");}

 

XSpi_Start(&Spi);
print("\nSPI initiated");

XSpi_IntrGlobalDisable(&Spi);

print("\nInterrupts disabled");

return 0;


}

 

I can see only up to sucess initialise in my sdk output terminal.

Please make some suggestions to make it work properly. Thanks in advance.

0 Kudos
3 Replies
sha@hys
Explorer
Explorer
9,222 Views
Registered: ‎05-31-2015

Hi,

 

Also I would like to know how to set spi slave select register when i have an external slave like external ADC and the spi outputs are ported to gpio pins of fpga. Actually in above case I have simply set the slave reg to 1. I could'nt find  specifications of actual register that is being set.

0 Kudos
9,149 Views
Registered: ‎05-27-2014

I would tell you to verify your interrupt connections. This is what got me on the path I am now of debugging the AXI IntC system. If this code is the same as the SDK version I'm using, then even when in polled mode, the interrupt subsystem is used. So if your interrupts are not properly connected, it will hang waiting for the interrupt bit to be set to indicate transmission is done.

0 Kudos
spochiraju
Visitor
Visitor
6,216 Views
Registered: ‎04-06-2014

I am having similar issue. please can anyone tell me what is the error in my code. status from spi_transfer is a success. 

 

I am using quad spi to talk to an external ADC device. I am unable to read data back from ADC. quad spi IP is configured to master. when I hook up my board to logic analyser, I do some read data but I am not able print it out or use it for any calculation. Also I see that data from ADC on logic analyser is available as the same clock that i send data to ADC.

Here is my code.

 

u8 wr_data[3];
u8 rd_data[3];
ConfigPtr = XSpi_LookupConfig(SpiDeviceID);
Status = XSpi_CfgInitialize(SpiInstancePtr, ConfigPtr,
ConfigPtr->BaseAddress);
Status = XSpi_SelfTest(SpiInstancePtr);
Status = XSpi_SetOptions(SpiInstancePtr, XSP_MASTER_OPTION | XSP_MANUAL_SSELECT_OPTION);
XSpi_Start(SpiInstancePtr);
XSpi_IntrGlobalDisable(SpiInstancePtr);

PmodCtlSys_SndBuf[0] = 0x01;//start bit is lsb
PmodCtlSys_SndBuf[1] = 0xA0;//
PmodCtlSys_SndBuf[2] = 0x55;// can be anything.

XSpi_SetSlaveSelect(SpiInstancePtr, 0x01);
Status = XSpi_Transfer(SpiInstancePtr, wr_data, rd_data, 3);

 


Now here when i print rd_data, I get zero.

Please can anyone help me understand what the issue is and how to fix it.

Mark

0 Kudos