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: 
Explorer
Explorer
571 Views
Registered: ‎04-16-2015

GPIO in MicroBlaze for custom IO

Hello all,

 

I added two IP axi_gpio with the custom interface to microblaze design described in the video:
https://www.xilinx.com/video/hardware/creating-a-simple-microblaze-design-in-ip-integrator.html

One axi_gpio - for output of 32 bits,
another - for input of 32 bits.


Then new gpio's ports were commented in the entity of the wrapper:
--gpio_1_tri_o : out STD_LOGIC_VECTOR ( 31 downto 0 );

--gpio_tri_i : in STD_LOGIC_VECTOR ( 31 downto 0 );
and declared as the signals.

 

Then I have done simple loop for these signals in the wrapper:
gpio_tri_i <= gpio_1_tri_o;

 

In the program (hello_world_1.c) within SDK I used following commands for writing and reading of the code:
*(int*)(GPIO1) = 0xAA;

*(int*)(GPIO2 | 0x0004) = 0xFFFFFFFF;    

temp4 = *(int*)(GPIO2);

xil_printf("GPIO2 = %X \r\n",temp4);

 

Similar command succesfully performs output of the one byte code to the led_8bits  through axi_gpio.
But the program outs to terminal:
"GPIO2 = 0"
So, something do not works properly.

 

Please suggest me, how do make correctly
output of custom code from Micro Blaze block design to the top level
and input of custom code from top level to the Micro Blaze block design.
I would like to use axi_gpio blocks or similar.

 

Thank you,

Best regards,
Viktor.
P.S. I used Vivado 2016.4
Complete project can be found here:
https://drive.google.com/file/d/1ARdNSVgvmugoeo-XwBTCVfj1mhCUTCEv/view?usp=sharing

 

 

0 Kudos
2 Replies
Moderator
Moderator
502 Views
Registered: ‎07-31-2012

Re: GPIO in MicroBlaze for custom IO

Hi @pulsar,

 

*(int*)(GPIO1) = 0xAA;

temp4 = *(int*)(GPIO2);

xil_printf("GPIO2 = %X \r\n",temp4);

 

In above logic looks like you have connected GPIO1(output port) to LEDs which works but same GPIO2 based address read '0' data.

This could be hardware design issue  i.e. the loopback internally done between GPIO1 and GPIO2.

 

How is blocks interfaced for this design and are you expecting doing design loopback do without software application loopback?

 

Regards

Praveen


-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 Kudos
Explorer
Explorer
496 Views
Registered: ‎04-16-2015

Re: GPIO in MicroBlaze for custom IO

 


Hi, Praveen

 

Thank you for your answer.


>In above logic looks like you have connected GPIO1(output port) to LEDs

No,
GPIO1 defines Offset Address for custom 32 bits output
GPIO2 - for custom 32 bits input
and
GPIO - for output to led_8bits.

 

Here is all macroses for the Offset Address used in the program:
#define GPIO 0x40000000 // output to led_8bits
#define GPIO1 0x40010000 // custom 32 bits output
#define GPIO2 0x40020000 // custom 32 bits input
#define SLMB_DATA 0x00000000

File Address_Editor.png is the screenshot of the Block Design's Address Editor.

It can be found here:

https://drive.google.com/file/d/1pE-V2p66n9PbaPlMSDShsu8bE7iV1Wup/view?usp=sharing

 

Below you can look complete sourse code of the program.
Complete project can be found here:
https://drive.google.com/file/d/1ARdNSVgvmugoeo-XwBTCVfj1mhCUTCEv/view?usp=sharing

 

>How is blocks interfaced for this design and are you expecting doing design loopback do without software application loopback?
I did output to the custom GPIO1 32 bits output with the similar command as for led_8bits (which works properly).
Yes, I expected that it will do output as the similar command for led_8bits.

Hardware loop consists from 1 string in the wrapper:
gpio_tri_i <= gpio_1_tri_o;
And I expected again to read the code from GPIO2 32 bits input port
(after successful output to the GPIO1, as I expected earlier).

 

If I correctly understand your question, my expectations were vain and these two operations -
ouput to the custom GPIO 32 bits
and the input from custom GPIO 32 bits
(for the simple hardware loop)
are impossible without additional software application loopback.

 

Unfortunately I do not familiar with this theme.
Please suggest me how to do it correctly, or where to read about it

or to find the example.

 

Many thanks,

Best regards,
Viktor.
=================================================
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
//#include "xgpio.h"

 

#define GPIO 0x40000000 // output to led_8bits
#define GPIO1 0x40010000 // custom 32 bits output
#define GPIO2 0x40020000 // custom 32 bits input
#define SLMB_DATA 0x00000000

 

int main()
{
unsigned i=0,j=0;
int temp3=0, temp4=0;


init_platform();

 

for(i=0;i<6;i++) print("\n\r");
print("=================Hello World=================\n\r");
print("-- Entering main() --\r\n\n");

 

for(i=0;i<=0xFF;i++)
{
*(int*)(GPIO) = i; // output to led_8bits
for(j=0;j<=0xFFFF;j++) i=i; // cycle for delay
}

*(int*)(GPIO) = 0xF1;  // output to led_8bits

 

*(int*)(GPIO1) = 0xF0F0F0FF;    // output to the GPIO1 

 

*(int*)(GPIO2 | 0x0004) = 0xFFFFFFFF;    // configure GPIO2 as input
temp4 = *(int*)(GPIO2);    // input from the GPIO2
xil_printf("GPIO2 = %X \r\n",temp4);

 

// hi-adress test of BRAM DATA
print("\n\r");
print("hi-adress test of BRAM DATA \n\r");
temp3 = 0xBAA07FFC;
*(int*)(SLMB_DATA | 0x7FFC) = temp3;

temp3 = 0xBEE07FF8;
*(int*)(SLMB_DATA | 0x7FF8) = temp3;

temp4 = *(int*)(SLMB_DATA | 0x7FFC);
xil_printf("temp4 (addr = 0x7FFC) = %X \r\n",temp4);

temp4 = *(int*)(SLMB_DATA | 0x7FF8);
xil_printf("temp4 (addr = 0x7FF8) = %X \r\n",temp4);


cleanup_platform();
return 0;
}

 

0 Kudos