Hello,
Are you able to help me alittle bit with my SPI? I am facing alot of trouble with it.
I directed my SPI1 to PMOD, then got some code running. I am connecting a 8 bit shift register to the PMOD and im sending 1 byte and reading 2 bytes - which means that every data the data i send, must be received back on the 2nd location of the buffer.
This WORKS - but only sometimes.! i run the code, and it returns without any errors, but when i run it again, it gets stuck in the XSpiPs_PolledTransfer command, and im not sure why.. attached in the function.
I will really appreciate it if you could take a look at it!!!
Thank you in advance..
#define DS26518_SPI_SELECTt0x01
/**
int SpiPsreadIDR(u16 DeviceId)
{
tint Status;
tu8 writeBuffer2[2];
tu8 readBuffer2[2];
treadBuffer2[0]=0x00;
treadBuffer2[1]=0x00;
treadBuffer2[2]=0x00;
twriteBuffer2[0]=0xBF;
twriteBuffer2[1]=0xAA;
txil_printf("Initializing config
r");
tXSpiPs_Config *SpiConfig;
tSpiConfig = XSpiPs_LookupConfig(DeviceId);
tif (NULL == SpiConfig) {
ttreturn XST_FAILURE;
t}
tStatus = XSpiPs_CfgInitialize(&Spi, SpiConfig, SpiConfig->BaseAddress);
tif (Status != XST_SUCCESS) {
ttreturn XST_FAILURE;
t}
tXSpiPs_SetOptions(&Spi, XSPIPS_MASTER_OPTION |
ttt XSPIPS_FORCE_SSELECT_OPTION);
tXSpiPs_SetClkPrescaler(&Spi, XSPIPS_CLK_PRESCALE_64);
tXSpiPs_SetSlaveSelect(&Spi, DS26518_SPI_SELECT);
tXSpiPs_PolledTransfer(&Spi,writeBuffer2,readBuffer2,2);
txil_printf("IDR value is: MSB: %x
r", writeBuffer2[0]);
txil_printf("IDR value is: LSB: %x
r", writeBuffer2[1]);
txil_printf("IDR value is: MSB: %x
r", readBuffer2[0]);
txil_printf("IDR value is: MSB: %x
r", readBuffer2[1]);
treturn XST_SUCCESS;
}