I'm currently facing some strange behavior of an SPI interface on my Eclypse Z7:
Everything works perfectly fine as long as the board is programmed through QSPI for debugging - the self-test is good, with no errors, and I can use the device as expected.
However, once I try to program it via JTAG (or from SD card), the SPI self-test fails with error #14, indicating an unexpected register value in the configuration register:
#define XST_REGISTER_ERROR 14L /*!< A register did not contain the expected value */
Also, when trying to send some data after the failed test, the code gets stuck in the sending / receiving process.
We're using SPI #1 as an output to control an external DAC through EMIO. The signal is routed through the PL to one of the PMOD connectors, as shown in the attached screenshot.
(SPI #0 is also used as an input to read from an external ADC but works without any problems in both cases, even after programming the device via JTAG. )
So only SPI #1 is affected by the problem.
Both SPI devices are initialized by the same code (shown below). The only difference is their usage in the PL.
int setupSPI(XSpiPs *spiPtr, u16 deviceID, u8 SlaveSelectAddr, bool clkPhaseOne, u8 clkPrescaler) {
xil_printf("Setting up SPI instance...\r\n");
int Status;
XSpiPs_Config *Config;
/*
* Initialize the SPI driver so that it's ready to use
* Look up the configuration in the config table, then initialize it.
*/
Config = XSpiPs_LookupConfig(deviceID);
if (NULL == Config) {
xil_printf("ERROR: SPI setup failed on configuration lookup.\r\n");
return XST_FAILURE;
}
Status = XSpiPs_CfgInitialize(spiPtr, Config, Config->BaseAddress);
if (Status != XST_SUCCESS) {
xil_printf("ERROR: SPI setup failed during config initialization.\r\n");
return XST_FAILURE;
}
/*
* Perform a self-test.
*/
sleep(1);
Status = XSpiPs_SelfTest(spiPtr);
if (Status != XST_SUCCESS) {
xil_printf("WARNING: SPI self-test error #%d\r\n", Status);
//return XST_FAILURE;
}
/*
* Set the SPI device as a master with manual start and manual
* chip select mode options
*/
if (clkPhaseOne) {
XSpiPs_SetOptions(spiPtr, XSPIPS_MANUAL_START_OPTION | \
XSPIPS_MASTER_OPTION | XSPIPS_FORCE_SSELECT_OPTION | XSPIPS_CLK_PHASE_1_OPTION);
} else {
XSpiPs_SetOptions(spiPtr, XSPIPS_MANUAL_START_OPTION | \
XSPIPS_MASTER_OPTION | XSPIPS_FORCE_SSELECT_OPTION);
}
/*
* Set the SPI device pre-scaler to divide e.g. by 8, resulting in a clk rate of ~20,833 MHz (ADC maximum: 63 MHz / DAC maximum: 20 MHz)
*/
XSpiPs_SetClkPrescaler(spiPtr, clkPrescaler);
// Set Slave select output.
Status = XSpiPs_SetSlaveSelect(spiPtr, SlaveSelectAddr);
if (Status != XST_SUCCESS) {
xil_printf("ERROR: SPI failed setting Slave Select.\r\n");
return XST_FAILURE;
}
xil_printf("--> SPI setup successful.\r\n");
return XST_SUCCESS;
}//setupSPI
Both, XSpiPs_LookupConfig and XSpiPs_CfgInitialize don't return any errors, no matter how the Eclypse Z7 is programmed.
Question
gueste
Hello everyone,
I'm currently facing some strange behavior of an SPI interface on my Eclypse Z7:
Everything works perfectly fine as long as the board is programmed through QSPI for debugging - the self-test is good, with no errors, and I can use the device as expected.
However, once I try to program it via JTAG (or from SD card), the SPI self-test fails with error #14, indicating an unexpected register value in the configuration register:
#define XST_REGISTER_ERROR 14L /*!< A register did not contain the expected value */
Also, when trying to send some data after the failed test, the code gets stuck in the sending / receiving process.
We're using SPI #1 as an output to control an external DAC through EMIO. The signal is routed through the PL to one of the PMOD connectors, as shown in the attached screenshot.
(SPI #0 is also used as an input to read from an external ADC but works without any problems in both cases, even after programming the device via JTAG. )
So only SPI #1 is affected by the problem.
Both SPI devices are initialized by the same code (shown below). The only difference is their usage in the PL.
int setupSPI(XSpiPs *spiPtr, u16 deviceID, u8 SlaveSelectAddr, bool clkPhaseOne, u8 clkPrescaler) { xil_printf("Setting up SPI instance...\r\n"); int Status; XSpiPs_Config *Config; /* * Initialize the SPI driver so that it's ready to use * Look up the configuration in the config table, then initialize it. */ Config = XSpiPs_LookupConfig(deviceID); if (NULL == Config) { xil_printf("ERROR: SPI setup failed on configuration lookup.\r\n"); return XST_FAILURE; } Status = XSpiPs_CfgInitialize(spiPtr, Config, Config->BaseAddress); if (Status != XST_SUCCESS) { xil_printf("ERROR: SPI setup failed during config initialization.\r\n"); return XST_FAILURE; } /* * Perform a self-test. */ sleep(1); Status = XSpiPs_SelfTest(spiPtr); if (Status != XST_SUCCESS) { xil_printf("WARNING: SPI self-test error #%d\r\n", Status); //return XST_FAILURE; } /* * Set the SPI device as a master with manual start and manual * chip select mode options */ if (clkPhaseOne) { XSpiPs_SetOptions(spiPtr, XSPIPS_MANUAL_START_OPTION | \ XSPIPS_MASTER_OPTION | XSPIPS_FORCE_SSELECT_OPTION | XSPIPS_CLK_PHASE_1_OPTION); } else { XSpiPs_SetOptions(spiPtr, XSPIPS_MANUAL_START_OPTION | \ XSPIPS_MASTER_OPTION | XSPIPS_FORCE_SSELECT_OPTION); } /* * Set the SPI device pre-scaler to divide e.g. by 8, resulting in a clk rate of ~20,833 MHz (ADC maximum: 63 MHz / DAC maximum: 20 MHz) */ XSpiPs_SetClkPrescaler(spiPtr, clkPrescaler); // Set Slave select output. Status = XSpiPs_SetSlaveSelect(spiPtr, SlaveSelectAddr); if (Status != XST_SUCCESS) { xil_printf("ERROR: SPI failed setting Slave Select.\r\n"); return XST_FAILURE; } xil_printf("--> SPI setup successful.\r\n"); return XST_SUCCESS; }//setupSPI
Both, XSpiPs_LookupConfig and XSpiPs_CfgInitialize don't return any errors, no matter how the Eclypse Z7 is programmed.
I'm glad for any advice, thanks in advance.
Link to comment
Share on other sites
9 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now