[Xilinx AX7103 MicroBalze study notes 3] MicroBlaze uses AXI GPIO to control LED lights

Hits: 0

Table of contents

experimental task

Experimental block diagram

Hardware Design (Living part)

Configure IP

Add constraint information

Software design (SDK part)

Board Level Verification

Summarize

Past series of blogs

experimental task

This experiment realizes the control of LED lights by using AXI [GPIO] IP.

Experimental block diagram

The experimental block diagram is as follows. Compared with the previous experimental project block diagram of Hello World, this experiment only adds the IP core of AXI GPIO. Both AXI GPIO and AXI [UART] are interconnected with MicroBlaze through the AXI Interconnect module. The Microblaze processor outputs the control signal of the LED light and transmits it to the AXI GPIO module through the AXI Interconnect interconnection module. The AXI GPIO module parses the LED light control signal according to the AXI4-Lite protocol. , output to the LED pin of the FPGA, so as to control the LED light.

Hardware Design ( [Vivado] Section)

Since most of the operations are similar to the experimental operations of Hello World, some unimportant steps are simplified.

Based on the Hello World experiment, click File->Project->Save As and rename the project to axi_gpio_led.

Configure IP

Open Block Design, add the AXI GPIO block, and configure it.

Configure the bit width of GPIO as 4, because there are 4 LED lights to be controlled, and the rest parameters can be kept as default.

Click Auto connect, the system will connect automatically.

Re- “Generate Output Products” and “Create HDL Wrapper”

Generate Output Products mainly updates the IP parameters and connection information to the Project, and also checks for errors.

The role of Create HDL Wrapper is to instantiate each module or code file into the top-level file.

Add constraint information

In this project, it is necessary to additionally bind the LEDs and bind them with their own development board pin constraints.

set_property PACKAGE_PIN T6 [get_ports reset_n]
set_property IOSTANDARD LVCMOS15 [get_ports reset_n]
set_property PACKAGE_PIN N15 [get_ports uart_txd]
set_property PACKAGE_PIN P20 [get_ports uart_rxd]
set_property IOSTANDARD LVCMOS33 [get_ports uart_rxd]
set_property IOSTANDARD LVCMOS33 [get_ports uart_txd]
set_property PACKAGE_PIN R4 [get_ports diff_clk_clk_p]
set_property IOSTANDARD DIFF_SSTL15 [get_ports diff_clk_clk_p]
create_clock -period 5.000 [get_ports diff_clk_clk_p]

set_property PACKAGE_PIN B13 [get_ports {LED_tri_io[0]}]
set_property PACKAGE_PIN C13 [get_ports {LED_tri_io[1]}]
set_property PACKAGE_PIN D14 [get_ports {LED_tri_io[2]}]
set_property PACKAGE_PIN D15 [get_ports {LED_tri_io[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {LED_tri_io[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {LED_tri_io[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {LED_tri_io[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {LED_tri_io[0]}]

Finally, generate a bitstream file, import it into the hardware, start the SDK, and enter the design of the software part.

Software design (SDK part)

Like the previous Hello World experimental project, create a new project named axi_gpio_led, and add a new code file in the src folder named main.c.

#include "xparameters.h"
#include "xgpio.h"
#include "xil_printf.h"
#include "sleep.h"

#define GPIO_DEVICE_ID  XPAR_GPIO_0_DEVICE_ID
#define LED_CHANNEL 1
#define LED_DELAY   50000000

XGpio Gpio; 

int main(void)
{
    int Status;
    int i=0;

    //Initialize gpio
    Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);
    if (Status != XST_SUCCESS) {
        xil_printf("Gpio Initialization Failed\r\n");
        return XST_FAILURE;
    }

    //Set data direction 0 as output 1 as input 
    XGpio_SetDataDirection(&Gpio, LED_CHANNEL, 0 );

    //cycle blinking LED

    while ( 1 ) {
     //Write data to the specified channel, and the LED flows every 0.5 seconds 
    XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, 0x01 << i);
     //loop count, indicating which number of lights are on 
    if (i == 3 )
    i = 0 ;
     else 
    i = i + 1 ;
     // delay 0.5 seconds 
    usleep( 500000 );
     }
    return 0;
}
//The code comes from the punctual atom

The code design process is:

  1. Initialize GPIO first
  2. Set the direction of the data, because the gpio is used to control the LED, so it is the output
  3. In an infinite loop, write data to the channel, let the LED form a pipeline

Board Level Verification

Burn the program into the board to verify the correctness of the program, and you can see that the LED flashes in the form of flowing water.

Summarize

Compared with the Hello World experiment, this experiment has made a small change, only adding an AXI GPIO module to control the LED.

Past series of blogs

[Xilinx AX7103 MicroBalze Study Notes 1] Introduction to MicroBlaze

[Xilinx AX7103 MicroBalze study notes 2] MicroBlaze serial port sending Hello World experiment

[Xilinx AX7103 MicroBalze study notes 3] MicroBlaze uses AXI GPIO to control LED lights

​​​​​​​ [Xilinx AX7103 MicroBalze study notes 4] MicroBlaze button interrupt experiment

[Xilinx AX7103 MicroBalze study notes 5] MicroBlaze serial port interrupt experiment

[Xilinx AX7103 MicroBalze Study Notes 6] MicroBlaze Custom IP Core Packaging Experiment

[Xilinx AX7103 MicroBalze study notes 7] DDR reading and writing experiment of MicroBlaze AXI4 interface

Leave a Reply

Your email address will not be published.