Zynq FreeRTOS Interrupt Example Tutorial

Vivado – Creating a Project

  • Vivado version : v2020.1
  • Project name : zynq_freertos_interrupt
  • Project location : D:/test/zynq/zynq_freertos_interrupt
  • Project Type : RTL Project
  • Add Sources : [Next]
  • Add Constraints : [Next]
  • Default Part : Click the Boards, Select ZYNQ-7 ZC702 Evaluation Board

Block Design

  • IP INTEGRATOR -> Create Block Design
  • Design name : design_top
  • Add IP : ZYNQ7 Processing System
  • Double-click the ZYNQ7 Processing System
  • Click the Presets, Select ZC702
  • Page Navigator -> Interrupts -> Check Fabric Interrupts and PL-PS Interrupt Ports’ IRQ_F2P[15:0]
  • Click [OK]
zynq_irq_f2p

  • Click the Run Block Automation -> [OK]
  • Click the M_AXI_GP0_ACLK and drag to the FCLK_CLK0
  • Right Click and Run Create Port
zynq_create_port_interrupt

  • Port name : ext_irq
  • Direction : input
  • Type : Interrupt
  • Interrupt type : Level
  • Sensitivity : Active High
  • Click [OK]
  • Click the ext_irq and drag to the IRQ_F2P[0:0]
zynq_block_design_ext_irq

  • Click Validate Design (F6)
  • Click the Sources tab
  • Right-click design_top and select Create HDL Wrapper
  • Select Let Vivado manage wrapper and auto-update

Creating a Constraint File

  • Flow Navigator -> PROJECT MANAGER -> Add Sources -> Add or create constraints
  • [Next] -> [Create File]
  • File name : top
  • [OK] -> [Finish]
  • Edit the top.xdc file
    set_property PACKAGE_PIN G19 [get_ports ext_irq]
    set_property IOSTANDARD LVCMOS25 [get_ports ext_irq]

Compiling

  • Click Generate Bitstream

Exporting to Vitis and Launch

  • File -> Export -> Export Hardware -> Fixed -> [Next] -> Include bitstream -> [Next] -> [Next] -> [Finish]
  • Tools -> Launch Vitis IDE
  • Workspace : D:/test/zynq/zynq_freertos_interrupt/vitis

Vitis – Creating a Platform Project

  • Project name : hw_platform -> [Next]
  • Platform Project : Create from hardware specification (XSA) -> [Next]
  • [Browse] to D:/test/zynq/zynq_freertos_interrupt/design_top_wrapper.xsa
  • Operating system : freertos10_xilinx
  • Processor : ps7_cortexa9_0
  • Check Generate boot components -> [Finish]
  • Right Click hw_platform (Out-of-date) and Build Project

Vitis – Creating an Application Project

  • File -> New -> Application Project
  • [Next]
  • Platform : [Next]
  • Application project name : zynq_freertos_interrupt -> [Next]
  • Domain : [Next]
  • Templates : FreeRTOS Hello World -> [Finish]

Editing a freertos_hello_world.c and Compile, Run

  • Edit a freertos_hello_world.c
  • Build Project
  • Connect J17 USB UART and Run a Terminal Application, baudrate=115,200
  • Right Click zynq_freertos_interrupt [ freertos10_xilinx on ps7_cortexa9_0 ] and Run As -> Run Configurations…
  • Right Click Single Application Debug -> New Configuration
  • Click the Target Setup tab
  • Check the Use FSBL flow for initialization
  • [Apply] -> [Run]
  • Press the SW5 Button
hello_freertos_ext_irq

freertos_hello_world.c

void ExtIrq_Handler(void *InstancePtr)
{
  xil_printf("ExtIrq_Handler\r\n");
}

void interrupt_init()
{
  xPortInstallInterruptHandler(XPAR_FABRIC_EXT_IRQ_INTR, ExtIrq_Handler, (void *)NULL);
  vPortEnableInterrupt(XPAR_FABRIC_EXT_IRQ_INTR);
}

Download Source Files