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: 
Highlighted
Adventurer
Adventurer
195 Views
Registered: ‎06-22-2018

Why "XSpiPs_PolledTransfer()" will clear the slave select?

With "XSPIPS_FORCE_SSELECT_OPTION", it seems the user need manually assert the salve select signals using "XSpiPs_SetSlaveSelect()".  Then it's expected the slave select should be manually deassert by user too. But in "XSpiPs_PolledTransfer()", the code below will deassert the slave selects:

		/*
		 * Clear the slave selects now, before terminating the transfer.
		 */
		if (XSpiPs_IsManualChipSelect(InstancePtr) == TRUE) {
			ConfigReg = XSpiPs_ReadReg(InstancePtr->Config.BaseAddress,
						XSPIPS_CR_OFFSET);
			ConfigReg |= XSPIPS_CR_SSCTRL_MASK;
			XSpiPs_WriteReg(InstancePtr->Config.BaseAddress,
					 XSPIPS_CR_OFFSET, ConfigReg);
		}

IMHO, it's not reasonable. Because many EEPROM or other SPI device need the operation flow like below:

CS= low -> delay() -> CMD phase -> data phase -> CS=high -> delay().

If let user to deassert the chip select, then we can split the CMD phase the data phase. It's not comfortable to padding the data following the command everytime invoke the  "XSpiPs_PolledTransfer()".

 

 

0 Kudos
4 Replies
Voyager
Voyager
158 Views
Registered: ‎04-13-2015

Re: Why "XSpiPs_PolledTransfer()" will clear the slave select?

@diverger

The clock with that SPI controller only toggles when there is data in the TX FIFO; TX FIFO empty, no clock toggling. When reading from the SPI, each byte to read must be preceeded by a byte written to the TX FIFO. All SPI devices are static so when the clock is not toglling nothing happens.

If you want the CS to go up immediately after the last bit of the last byte is transferred, set the controller in automatic CS.  You have to be aware if your SW is to slow filling the TX FIFO the transfer could be terminated early because with the automatic CS, the transfer stops when the TX FIFO  becomes empty.

0 Kudos
Adventurer
Adventurer
139 Views
Registered: ‎06-22-2018

Re: Why "XSpiPs_PolledTransfer()" will clear the slave select?

I mean don't do any slave select/deselect operations in "XSpiPs_PolledTransfer()", but let the user do it. Only the user can assert/deassert the slave select, then he can invoke "XSpiPs_PolledTransfer()" any times when slave selected.

But the situation now is, the user selected the slave, because he want add some delay between CS asserting and data xfr, then he invoke "XSpiPs_PolledTransfer()", but that function will deselect the slave when exiting.

0 Kudos
Voyager
Voyager
131 Views
Registered: ‎04-13-2015

Re: Why "XSpiPs_PolledTransfer()" will clear the slave select?

@diverger

All designs & implementations involve assumptions and trade off - the BSP is no exception  You have access to the full BSP source code, and even better you can rebuild it, so tailor it to meet your needs.

0 Kudos
Adventurer
Adventurer
103 Views
Registered: ‎06-22-2018

Re: Why "XSpiPs_PolledTransfer()" will clear the slave select?

Yes. I've build one new "polled xfr" function based on the original one.

0 Kudos