I'm trying to make communicate between ps7_spi_0 and axi_quad_spi. This is block diagram. FCLK_CLK0 is 100 Mhz. SPI_0 is 166.666666 Mhz
C code :
/* * helloworld.c: simple test application * * This application configures UART 16550 to baud rate 9600. * PS7 UART (Zynq) is not initialized by this application, since * bootrom/bsp configures it to baud rate 115200 * * ------------------------------------------------ * | UART TYPE BAUD RATE | * ------------------------------------------------ * uartns550 9600 * uartlite Configurable only in HW design * ps7_uart 115200 (configured by bootrom/bsp) */ #include <stdio.h> #include "platform.h" #include "xil_printf.h" #include "xspips.h" #include "xspi.h" #include "sleep.h" #define SPI_DEVICE_ID XPAR_XSPIPS_0_DEVICE_ID #define QSPI_DEVICE_ID XPAR_SPI_0_DEVICE_ID static XSpiPs SpiInstance; static XSpi Spi; u16 TxBuffer[4]; u16 RxBuffer[4]; int main() { XSpiPs_Config *SpiConfig; int Status,i; init_platform(); int NumBytesRcvd; printf("SPI Example\n"); SpiConfig = XSpiPs_LookupConfig(SPI_DEVICE_ID); if (NULL == SpiConfig) { return XST_FAILURE; } Status = XSpiPs_CfgInitialize(&SpiInstance, SpiConfig,SpiConfig->BaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } Status = XSpiPs_SelfTest(&SpiInstance); if (Status != XST_SUCCESS) { return XST_FAILURE; } XSpiPs_SetOptions(&SpiInstance, XSPIPS_MASTER_OPTION | XSPIPS_FORCE_SSELECT_OPTION); XSpiPs_SetClkPrescaler(&SpiInstance, XSPIPS_CLK_PRESCALE_64); XSpi_Initialize( &Spi, QSPI_DEVICE_ID ); Status = XSpi_SelfTest( &Spi ); if (Status != XST_SUCCESS) { return XST_FAILURE; } XSpi_Reset(&Spi); XSpi_Start(&Spi); XSpi_IntrGlobalDisable(&Spi); TxBuffer[0] = 0xa0a0; TxBuffer[1] = 0x0505; TxBuffer[2] = 0xa0a0; TxBuffer[3] = 0x0505; while (1) { XSpiPs_SetSlaveSelect(&SpiInstance, 0x00); Status = XSpiPs_Transfer(&SpiInstance, (u8*)&TxBuffer, (u8*)&RxBuffer, 8); if(Status != XST_SUCCESS) { printf("XSpiPs_Transfer failed\n") } NumBytesRcvd = 0; //XSpi_SetControlReg(&Spi,0x60); XSpi_WriteReg((SpiInstance.SpiConfig.BaseAddr), XSPIPS_TXD_OFFSET, TxBuffer[0]); XSpi_WriteReg((SpiInstance.SpiConfig.BaseAddr), XSPIPS_TXD_OFFSET, TxBuffer[1]); //XSpi_SetControlReg(&Spi,0x02); XSpi_WriteReg((SpiInstance.SpiConfig.BaseAddr), XSPIPS_TXD_OFFSET, TxBuffer[2]); XSpi_WriteReg((SpiInstance.SpiConfig.BaseAddr), XSPIPS_TXD_OFFSET, TxBuffer[3]); while (!(XSpi_ReadReg(Spi.BaseAddr, XSP_SR_OFFSET) & XSP_SR_TX_EMPTY_MASK)); while ((XSpi_ReadReg(Spi.BaseAddr, XSP_SR_OFFSET) & XSP_SR_RX_EMPTY_MASK) == 0) { printf("In While\n"); RxBuffer[NumBytesRcvd++] = XSpi_ReadReg((Spi.BaseAddr), XSP_DRR_OFFSET); } for(i=0;i<4;i++){ printf("rx %04x \n", RxBuffer[i]); } usleep(1000000); } cleanup_platform(); return 0; }
Console (uart) out:
SPI Example In While In While In While In While In While In While rx a0a0 rx 0505 rx a0a0 rx 0505 XSpiPs_Transfer failed rx a0a0 rx 0505 rx a0a0 rx 0505 XSpiPs_Transfer failed In While In While In While In While rx a005 rx a005 rx a005 rx a005 XSpiPs_Transfer failed rx a005 rx a005 rx a005 rx a005 XSpiPs_Transfer failed In While In While In While In While rx a005 rx a005 rx a005 rx a005