11-26-2019 10:13 AM
Hello,
I would like to manually control the slave select line for the Quad SPI peripheral at a certain point in my C code. In PG153 I have read that bit[7] of the SPICR register can be used to toggle the slave select. However, I do not see any examples on how to do this in C code.
My Quad SPI is set up as follows in my C code:
/* normal mode AXI QUAD SPI Initialize */ ConfigPtr_spi = XSpi_LookupConfig(XPAR_AXI_QUAD_SPI_0_DEVICE_ID); Status = XSpi_CfgInitialize(&Spi_AXI, ConfigPtr_spi, XPAR_AXI_QUAD_SPI_0_BASEADDR); Status = XSpi_SetOptions(&Spi_AXI, XSP_MASTER_OPTION | XSP_MANUAL_SSELECT_OPTION | XSP_CLK_PHASE_1_OPTION); XSpi_Start(&Spi_AXI); XSpi_SetSlaveSelect(&Spi_AXI, 0x01); XSpi_IntrGlobalDisable(&Spi_AXI);
I need to do this to meet the requirements for a device. It requires that after a read command is received, the chip select signal remains active until a certain number of bytes are read in without the chip select toggling. Using the XSpi_Transfer() function, the chip select signal automatically toggles and I need to stop this from happening.
Thank you
11-30-2019 10:18 PM
https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/spi/src/xspi.c
Line nummber 846 is used to deassert the CS once the transfer completed.
If you don`t want to deassert the CS please comment the same line and test.
Regards,
Venu
11-30-2019 10:18 PM
https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/spi/src/xspi.c
Line nummber 846 is used to deassert the CS once the transfer completed.
If you don`t want to deassert the CS please comment the same line and test.
Regards,
Venu
03-17-2020 11:10 AM
03-17-2020 03:42 PM
@venui I have seen the function you mentioned before, xilinx provide an example for spi master where you use it for select the slave, is the file:
xspi_eeprom_example
path:
embeddedsw\XilinxProcessorIPLib\drivers\spi_v4_4\examples
I have a query in this part, I hope you could help me (line 263)
/* * Set the SPI device as a master and in manual slave select mode such * that the slave select signal does not toggle for every byte of a * transfer, this must be done before the slave select is set */ Status = XSpi_SetOptions(&Spi, XSP_MASTER_OPTION | XSP_MANUAL_SSELECT_OPTION); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Select the slave on the SPI bus, the EEPROM device so that it can be * read and written using the SPI bus */ Status = XSpi_SetSlaveSelect(&Spi, SEEPROM_SPI_SELECT); if (Status != XST_SUCCESS) { return XST_FAILURE; }
If you are configuring the slave select as manual, why can I see the code to select the slave but I don`t see the code to deselect it?, I expected to find something like this:
Status = XSpi_SetSlaveSelect(&Spi, 0); if (Status != XST_SUCCESS) { return XST_FAILURE; }
So, why do you select the slave but never deselect it if we are using "manual option" ???
thanks
03-20-2020 04:36 PM
Hi davidfhorowitz@lmco.com could you tell me which line did you have to uncomment to prevent the disabling of the SS?, I read the solution but it seems that the code has been updated and now that line is a comment, no code.
thanks
04-05-2020 06:40 AM - edited 04-05-2020 06:49 AM
Hi,
In the transfer functions assertion ans de-assertion of SS has been taken care.
XSpi_SetSlaveSelectReg(InstancePtr, InstancePtr->SlaveSelectMask); line in function definition of XSpi_Transfer function can be found in the end of function definition.
Regards,
Venu