cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
4,037 Views
Registered: ‎05-10-2013

SPI (MIO) hangs most of the time on zedboard

Hi,

 

I have forwarded SPI 1 prepherial  to MIO (PS PMOD on ZYNQ7020- ZEDBOARD). I am trying to transfer one bye of address and then reading response - my code works, sometimes, but most of the time it hangs on the polled transfer function.

I am using the XSpiPs librar and following the POLLED transfer example..

 

The code hangs at XSpiPs_PolledTransfer command waiting for the TX fifo to send data (Wait for the transfer to finish by polling Tx fifo status). What could possibly cause that?

 

Im clueless of ideas.. any help would be appreciated

 

My code is attached for reference.

 

#define DS26518_SPI_SELECT 0x01

/**
int SpiPsreadIDR(u16 DeviceId)
{
int Status;
u8 writeBuffer2[2];
u8 readBuffer2[2];

readBuffer2[0]=0x00;
readBuffer2[1]=0x00;
readBuffer2[2]=0x00;
writeBuffer2[0]=0xBF;
writeBuffer2[1]=0xAA;

xil_printf("Initializing config\n\r");
XSpiPs_Config *SpiConfig;

SpiConfig = XSpiPs_LookupConfig(DeviceId);
if (NULL == SpiConfig) {
return XST_FAILURE;
}
Status = XSpiPs_CfgInitialize(&Spi, SpiConfig, SpiConfig->BaseAddress);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}

XSpiPs_SetOptions(&Spi, XSPIPS_MASTER_OPTION |
XSPIPS_FORCE_SSELECT_OPTION);

XSpiPs_SetClkPrescaler(&Spi, XSPIPS_CLK_PRESCALE_64);
XSpiPs_SetSlaveSelect(&Spi, DS26518_SPI_SELECT);

XSpiPs_PolledTransfer(&Spi,writeBuffer2,readBuffer2,2);

xil_printf("IDR value is: MSB: %x \n\r", writeBuffer2[0]);
xil_printf("IDR value is: LSB: %x \n\r", writeBuffer2[1]);
xil_printf("IDR value is: MSB: %x \n\r", readBuffer2[0]);
xil_printf("IDR value is: MSB: %x \n\r", readBuffer2[1]);

return XST_SUCCESS;
}

0 Kudos
2 Replies
Highlighted
Visitor
Visitor
4,020 Views
Registered: ‎05-10-2013

Re: SPI (MIO) hangs most of the time on zedboard

PROBLEM FIXED.

 

For future reference, here is the answer::

 

To solve SPI problems (directed to PS in this time) pay attention to the following:

- update your xilinx tools to version 14.6: I am not sure if the problem is with the tools or the library itself (i beleive with BOTH), but moving to version 14.6 will solve 90% of the problems you will face with the SPI prepherial. In my case i evem used the -same- code, simply run using XPIPS library (spips_v1_05_a, before i was using spips_v1_02_a)..

 

-SS0 (chip select 0) will not function properly on MIO- if you direct your SPI1 prepherial to MIO (PS), then make use of SS1 and SS2 instead.. SS0 will not work.

 

Thank you

 

Highlighted
Observer
Observer
3,995 Views
Registered: ‎04-29-2013

Re: SPI (MIO) hangs most of the time on zedboard

Thanks for sharing your fix.

 

I was having the same issue (driver spin locks) and it went away after udpating.

0 Kudos