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
1,423 Views
Registered: ‎10-11-2017

AXI QUAD SPI code error

Jump to solution

Hello everyone!

I creat block design include Microblaze,AXI QUAD SPI and AXI GPIO.Here is my block design.

1.png

 

Here is my code.

#include "xparameters.h"
#include"xspi.h"
#include "xspi_l.h"
#include"xgpio.h"

#define SPI_MASTER_ID XPAR_SPI_0_DEVICE_ID
#define LED_ID XPAR_GPIO_0_DEVICE_ID
#define LED_CHANNEL 1
#define LED 1
int main(void)
{
XSpi spi_master;
XGpio led;
int Status;

XSpi_Config *ConfigPtr;
ConfigPtr = XSpi_LookupConfig(SPI_MASTER_ID);
if(ConfigPtr==NULL){
return XST_FAILURE;
}

Status = XSpi_CfgInitialize(&spi_master, ConfigPtr,ConfigPtr->BaseAddress);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
Status = XSpi_SetOptions(&spi_master, XSP_MASTER_OPTION |
XSP_MANUAL_SSELECT_OPTION);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
Status=XSpi_Start(&spi_master);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
XSpi_IntrGlobalDisable(&spi_master);

Status = XSpi_SetSlaveSelect(&spi_master,spi_master.SlaveSelectMask);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}

u8 sendbuf[3];
u8 receivebuf[3];
unsigned int ByteCount=3;
unsigned int i;
for(i=0;i<ByteCount;i++){
sendbuf[i]=i;
receivebuf[i]=0;
}

Status=XSpi_Transfer(&spi_master,sendbuf,
receivebuf,ByteCount);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
/************GPIO***************/
Status=XGpio_Initialize(&led,XPAR_GPIO_0_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
XGpio_SetDataDirection(&led,LED_CHANNEL,~LED);
XGpio_DiscreteWrite(&led,LED_CHANNEL,LED);
return XST_SUCCESS;
}

 

When I debug my code in Step Over mode in SDK,when executed the function XSpi_SetOptions(...),It return value 388,I don't konw why this is happen.Then I try to Step Into the function XSpi_SetOptions(...)   to see which scentence is wrong, I found it will runaway when execute the scentence:

ControlReg = XSpi_GetControlReg(InstancePtr);

It looks like can't read the control register.

However,When I Step into the  function ControlReg = XSpi_GetControlReg(InstancePtr) and then execute step over by over.It will execute OK and the  function XSpi_SetOptions(...)  can  return the right value(XST_SUCCESS).

why the function XSpi_SetOptions(...) will run error when in  Step Over mode,But  it can run right when Step into the function  and  then step over by over.

When I delete the function XSpi_SetOptions(...) and build again,The function XSpi_Start(...) can be execute right in Step Over mode;Inside this function it also include  XSpi_GetControlReg(...) and XSpi_SetControlReg(...),Shows it can read and write register successly.

why the function XSpi_SetOptions(...) can not  read and write register  successly while the function XSpi_Start(...)  can ?

I am using Vivado 2015.1 and SDK 2015.1 on windows 7.

I have tryed Vivado 2017.2 and SDK 2017.2 .It will runaway even  when  execute the function XSpi_CfgInitialize(...)  in step over mode.But if  you step into the function and then  execute step over by  over,it can run OK and return the XST_SUCCESS.

I am completely confused.

Can anybody help me?please.

0 Kudos
1 Solution

Accepted Solutions
Adventurer
Adventurer
2,058 Views
Registered: ‎10-11-2017

回复: AXI QUAD SPI code error

Jump to solution
I have solved it.

I found that when configure Microblaze without check 'Use Instruction and Data Caches',it will work normally.

But I don't konw why.
0 Kudos
3 Replies
Adventurer
Adventurer
2,059 Views
Registered: ‎10-11-2017

回复: AXI QUAD SPI code error

Jump to solution
I have solved it.

I found that when configure Microblaze without check 'Use Instruction and Data Caches',it will work normally.

But I don't konw why.
0 Kudos
Xilinx Employee
Xilinx Employee
1,354 Views
Registered: ‎02-01-2008

回复: AXI QUAD SPI code error

Jump to solution

In this type of design, you are not using the axi4 interface on the qspi controller which is used for linear address mode when reading only. And you do not want cache accesses to go to axiLite peripherals. So if you are not planning on adding DDR to the design, I suggest you remove the microblaze cache interface.

 

If you do plan on adding DDR, then make sure to review the microblaze advance cache tab address range used for cache accesses and make sure that address range only includes your DDR controller.

 

If you plan on using XIP mode, then you will have an AXI4 interface on the core which can be cached since it is for reading only.

0 Kudos
Adventurer
Adventurer
1,349 Views
Registered: ‎10-11-2017

回复: AXI QUAD SPI code error

Jump to solution

Thanks for your reply! @johnmcd

Now I know why.

 

0 Kudos