cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Jonas_C
Visitor
Visitor
530 Views
Registered: ‎05-10-2020

AXI Quad SPI

Jump to solution

Hello,

I tried to use Arty S7 EVB to send SPI signal, and use "Saleae logic Analyzer Tool" to get the data, but the data retrieved is not the data I want to send in the program.

Can someone help me see what I am doing wrong?

Thank for your time,

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xintc.h"
#include "xspi.h"

#define BUFFER_SIZE     8

static XIntc Intc;
static XSpi Spi;

volatile static int TransferInProgress;

int Error;

u8 WriteBuffer[BUFFER_SIZE]={0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
u8 ReadBuffer[BUFFER_SIZE]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

void SpiHandler(void *CallBackRef, u32 StatusEvent, unsigned int ByteCount)
{

    TransferInProgress = FALSE;

    if (StatusEvent != XST_SPI_TRANSFER_DONE) {
        Error++;
    }
}

int main()
{
    int Status;
    XSpi_Config *ConfigPtr;

    init_platform();

    ConfigPtr = XSpi_LookupConfig(XPAR_SPI_0_DEVICE_ID);
    if (ConfigPtr == NULL) return XST_DEVICE_NOT_FOUND;

    Status = XSpi_CfgInitialize(&Spi, ConfigPtr, ConfigPtr->BaseAddress);
    if (Status != XST_SUCCESS) return XST_FAILURE;

    Status = XSpi_SelfTest(&Spi);
    if (Status != XST_SUCCESS) return XST_FAILURE;

    Status = XIntc_Initialize(&Intc, XPAR_INTC_0_DEVICE_ID);
    if(Status != XST_SUCCESS) return XST_FAILURE;

    Status = XIntc_Connect(&Intc, XPAR_INTC_0_SPI_0_VEC_ID,
                (XInterruptHandler)XSpi_InterruptHandler,
                (void *)&Spi);
    if(Status != XST_SUCCESS) return XST_FAILURE;

    Status = XIntc_Start(&Intc, XIN_REAL_MODE);
    if(Status != XST_SUCCESS) return XST_FAILURE;

    XIntc_Enable(&Intc, XPAR_INTC_0_SPI_0_VEC_ID);

    Xil_ExceptionInit();

    Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
                (Xil_ExceptionHandler)XIntc_InterruptHandler,
                &Intc);

    Xil_ExceptionEnable();

    XSpi_SetStatusHandler(&Spi, &Spi, (XSpi_StatusHandler)SpiHandler);

    Status = XSpi_SetOptions(&Spi, XSP_MASTER_OPTION |
                                   XSP_MANUAL_SSELECT_OPTION);
    if (Status != XST_SUCCESS) return XST_FAILURE;

    Status = XSpi_SetSlaveSelect(&Spi, 1);
    if (Status != XST_SUCCESS) return XST_FAILURE;

    XSpi_Start(&Spi);
	while(1){
		for(int i=0; i<BUFFER_SIZE; i++){
			WriteBuffer[i] = i+0xA0;
			ReadBuffer[i] = 0;
		}

		for(int i=0; i<8; i++){
			TransferInProgress = TRUE;
			XSpi_Transfer(&Spi, WriteBuffer, ReadBuffer, BUFFER_SIZE);
			while (TransferInProgress);
		}

		xil_printf("SPI Transfer Finished! (Error Count= %d \n\r", Error);
		cleanup_platform();
	}
    return 0;
}

 

clk use 100MHzclk use 100MHz

 

IP ConfigurationIP Configuration

 

Analyzer tool read dataAnalyzer tool read data

 

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
venui
Moderator
Moderator
461 Views
Registered: ‎04-09-2019

Hi ,

Can you probe the same signals from CRO and re-confirm.

Regards,

Venu

View solution in original post

4 Replies
venui
Moderator
Moderator
462 Views
Registered: ‎04-09-2019

Hi ,

Can you probe the same signals from CRO and re-confirm.

Regards,

Venu

View solution in original post

Jonas_C
Visitor
Visitor
426 Views
Registered: ‎05-10-2020
Hi Venu
Thank you for your suggestion.

The CRO measured the signal to be correct. It seems to be a problem with my PC Tool.
0 Kudos
dimpy
Adventurer
Adventurer
36 Views
Registered: ‎06-05-2020

Hello @Jonas_C 

Can you please tell me the procedure you followed?

I am doing the same but i am not getting any signal on the oscilloscope.

Kindly help me.

0 Kudos
Jonas_C
Visitor
Visitor
11 Views
Registered: ‎05-10-2020

Hi dimpy

At that time, I just watched YOUTUBE to learn.
Attached is a video of learning at that time.
Hope it helps you.

https://youtube.com/playlist?list=PLj4QI1KaYRNbffMxNHRet8KVNTyfyDvPN

0 Kudos