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: 
Adventurer
Adventurer
573 Views
Registered: ‎01-26-2017

Using XGpio to interface from MicroBlaze to PL

Jump to solution

Hi, 

 

I am currently working on a design that copies data from MicroBlaze to PL DDR4 via AXI-DMA. After the copying is completely done, I want to flag that the DDR4 can now be read on PL side. To do this, I opted to connect an AXI-GPIO as output, which should mean I can write data to the GPIO and then use the GPIO in PL as flags. To do this, I connected the GPIO in block design to be a slave to the MicroBlaze, which seems fine as the address editor shows the memory range of the GPIO at 0x4000000 to 0x4000FFFF. I made the output of the GPIO to be external, and then port map this to a signal, which in turn is used in flow control etc. 

 

My method for testing this is in my MicroBlaze code, I insert a breakpoint before the flag writes, then in an ILA core, I use the flag on PL side as a trigger. I program in debug mode, then idle the ILA to wait for trigger. I go back to SDK and resume the code, but the trigger is never asserted. 

 

I have never used AXI GPIO before so I'm not sure if I have the process correct, but it seems straightforward. However, there is no flag signal so I must have gone wrong somewhere: 

Here is the code that should be writing to the GPIO from PS side:

xil_printf("Initialising AXI-GPIO flags\n");
Status = XGpio_Initialize(&Gpio, GPIO_EXAMPLE_DEVICE_ID);
if (Status != XST_SUCCESS) {
xil_printf("Gpio Initialization Failed\r\n");
return XST_FAILURE;
}
xil_printf("GPIO base address is: %x\n", Gpio.BaseAddress);
xil_printf("GPIO isReady: %x\n", Gpio.IsReady);
xil_printf("GPIO dualChannel: %x\n", Gpio.IsDual);
xil_printf("GPIO interrupt ready: %x\n", Gpio.InterruptPresent);
xil_printf("GPIO direction is: %x\n", XGpio_GetDataDirection(&Gpio,1));
// set all data to be output, on channel 1
XGpio_SetDataDirection(&Gpio, 1, 0x00000000);
// write flags to all be high
xil_printf("GPIO flags set");
XGpio_DiscreteWrite(&Gpio, 1, 0xFFFFFFFF);

 

Here is the UART output showing that the GPIO has been initialized with correct addresses etc:

 

--- Entering main() ---
Info: DMA simple transfer started
Info: DMA simple transfer done
Info: DMA simple transfer started
Info: DMA simple transfer done
DMA transfer to DDR4 complete
Initialising AXI-GPIO flags
GPIO base address is: 40000000
GPIO isReady: 11111111
GPIO dualChannel: 0
GPIO interrupt ready: 0
GPIO direction is: 0
GPIO flags set

 

And the base address matches

axi_gpio.PNG

And here is the BD, where GPIO can be seen to be a slave of MicroBlaze:

bd_gpio.PNG

Thanks for your time.

--- Estimated Development time: 2*Pi*(planned completion date) ---
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer
Adventurer
489 Views
Registered: ‎01-26-2017

Re: Using XGpio to interface from MicroBlaze to PL

Jump to solution

Yes, changing the AXI IP block to be Interconnect instead of Smartconnect fixed the issue.

 

Originally I had smartconnect as the AXI master and GPIO block as the slave, I changed this to have AXI interconnect as the master and it works now. I guess for connecting to peripherals it might be best to try regular interconnect first. 

 

--- Estimated Development time: 2*Pi*(planned completion date) ---
0 Kudos
5 Replies
Explorer
Explorer
539 Views
Registered: ‎10-05-2010

Re: Using XGpio to interface from MicroBlaze to PL

Jump to solution

Your GPIO only has one channel; I believe that should be channel 0, not channel 1.

 

For example:

XGpio_SetDataDirection(&Gpio, 0, 0x00000000);

XGpio_DiscreteWrite(&Gpio, 0, 0xFFFFFFFF);

 

---

Joe Samson

Tags (2)
0 Kudos
Adventurer
Adventurer
534 Views
Registered: ‎01-26-2017

Re: Using XGpio to interface from MicroBlaze to PL

Jump to solution
Hi Joe - I will check that asap and come back to kudo and solved if it works. Thanks heaps
--- Estimated Development time: 2*Pi*(planned completion date) ---
0 Kudos
Adventurer
Adventurer
514 Views
Registered: ‎01-26-2017

Re: Using XGpio to interface from MicroBlaze to PL

Jump to solution

Hi @josephsamson

 

I tried channel = 0 like you suggested, but that makes my MicroBlaze program hang indefinitely. I know why though: The debugger shows that in assembly it hangs on: 

 

00005bac:   bnei          r3 , 0            ; addr=0x00005bac: Xil_Assert + 0x0000003c

 

And the definition of XGpio_DiscreteWrite shows that for false conditions, the program will wait infinitely due to AssertWait:

 

void XGpio_DiscreteWrite(XGpio * InstancePtr, unsigned Channel, u32 Data)
{

Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Xil_AssertVoid((Channel == 1) ||
((Channel == 2) && (InstancePtr->IsDual == TRUE)));
XGpio_WriteReg(InstancePtr->BaseAddress,
((Channel - 1) * XGPIO_CHAN_OFFSET) + XGPIO_DATA_OFFSET,
Data);

}

 

The third assert indicates that if there is one channel, it must be equal to channel 1 (or channel 2 in the case that there are two)

 

So I think I was originally correct in writing Channel = 1. I'm going to continue to try and debug, thanks for the suggestion anyway, I thought the channel was the most logical thing that could be going wrong...

--- Estimated Development time: 2*Pi*(planned completion date) ---
0 Kudos
Adventurer
Adventurer
454 Views
Registered: ‎01-26-2017

Re: Using XGpio to interface from MicroBlaze to PL

Jump to solution

Update: Someone with much more experience than me suggested using peripheral interconnect instead of AXI Smartconnect to drive the AXI GPIO. Now the bus values actually change, although I haven't verified if the data is correct yet. 

--- Estimated Development time: 2*Pi*(planned completion date) ---
0 Kudos
Highlighted
Adventurer
Adventurer
490 Views
Registered: ‎01-26-2017

Re: Using XGpio to interface from MicroBlaze to PL

Jump to solution

Yes, changing the AXI IP block to be Interconnect instead of Smartconnect fixed the issue.

 

Originally I had smartconnect as the AXI master and GPIO block as the slave, I changed this to have AXI interconnect as the master and it works now. I guess for connecting to peripherals it might be best to try regular interconnect first. 

 

--- Estimated Development time: 2*Pi*(planned completion date) ---
0 Kudos