{"id":1566,"date":"2022-11-17T21:22:29","date_gmt":"2022-11-17T13:22:29","guid":{"rendered":"http:\/\/www.hellofpga.com\/?p=1566"},"modified":"2025-05-12T17:03:30","modified_gmt":"2025-05-12T09:03:30","slug":"interrupt-2","status":"publish","type":"post","link":"http:\/\/www.hellofpga.com\/index.php\/2022\/11\/17\/interrupt-2\/","title":{"rendered":"\u57fa\u4e8eEBAZ4205\u7684PS\u5b9e\u9a8c\u56db \u5916\u90e8\u4e2d\u65ad\u5b9e\u9a8c"},"content":{"rendered":"\n<p>\u524d\u4e00\u8282\u7684\u6309\u952e\u7684\u4ee3\u7801\uff0c\u662f\u5728\u4e3b\u7a0b\u5e8f\u4e2d\u4e0d\u505c\u7684\u8f6e\u56de\u53bb\u626b\u63cfIO\u7684\u72b6\u6001\u6765\u8fbe\u5230\u6309\u952e\u68c0\u6d4b\u7684\u76ee\u7684\uff0c\u5bf9\u4e8e\u5c0f\u578b\u7684\u7cfb\u7edf\u6765\u8bf4\u6ca1\u4ec0\u4e48\u95ee\u9898\uff0c\u4f46\u662f\u5bf9\u4e8e\u5927\u578b\u590d\u6742\u7684\u7cfb\u7edf\u7a0b\u5e8f\u6765\u8bf4\uff0c\u5982\u679cmain\u7684\u4e3b\u5faa\u73af\u4e2d\u8981\u5904\u7406\u5f88\u591a\u4e8b\u52a1\uff0c\u5bf9\u4e8eIO\u7684\u68c0\u6d4b\u6216\u8005\u8bf4\u5bf9\u4e8e\u5916\u90e8\u4e8b\u4ef6\u7684\u89e6\u53d1\u5c31\u4e0d\u80fd\u53ca\u65f6\u7684\u8fdb\u884c\u54cd\u5e94\u4e86\uff0c\u5e76\u4e14\u6309\u952e\u5faa\u73af\u672c\u8eab\u4e5f\u5360\u7528\u4e86\u7cfb\u7edf\u8d44\u6e90\uff0c\u8fd9\u4e2a\u65f6\u5019\u5916\u90e8\u4e2d\u65ad\u7684\u91cd\u8981\u6027\u5c31\u51f8\u663e\u51fa\u6765\u4e86\u3002<\/p>\n\n\n\n<p>\u5916\u90e8\u4e2d\u65ad\u53ef\u4ee5\u8ba9MCU\u5b9e\u65f6\u5730\u5904\u7406\u5916\u90e8\u4e8b\u4ef6\uff0c\u5f53\u5916\u90e8\u4e8b\u4ef6\u53d1\u751f\u65f6\uff0c\u7cfb\u7edf\u7684\u4e2d\u65ad\u673a\u5236\u5c06\u8feb\u4f7fCPU\u6682\u505c\u6b63\u5728\u6267\u884c\u7684\u7a0b\u5e8f\uff0c\u8f6c\u800c\u53bb\u8fdb\u884c\u4e2d\u65ad\u4e8b\u4ef6\u7684\u5904\u7406\uff1b\u4e2d\u65ad\u5904\u7406\u5b8c\u6bd5\u540e\uff0e\u53c8\u8fd4\u56de\u88ab\u4e2d\u65ad\u7684\u7a0b\u5e8f\u5904\uff0c\u7ee7\u7eed\u6267\u884c\u4e0b\u53bb\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5b9e\u9a8c\u5185\u5bb9\u9002\u7528\u4e8e\u5e02\u9762\u4e0a\u529f\u80fd\u6b63\u5e38\u7684EBAZ4205\u7684\u677f\u5b50<\/strong><\/li>\n\n\n\n<li><strong>\u672c\u6b21\u5b9e\u9a8c\u9700\u8981\u8fde\u63a5\u672c\u7ad9\u70b9\u7684EBAZ4205\u8f6c\u63a5\u677f<\/strong><\/li>\n\n\n\n<li>\u672c\u6b21\u5b9e\u9a8c\u6ca1\u6709\u7528\u5230PL\u7aef\u6676\u632f<\/li>\n\n\n\n<li><strong>\u672c\u6587\u5728 vivado2018.3\u7248\u672c\u4e0a\u6f14\u793a<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u786c\u4ef6\u4ecb\u7ecd<\/strong><\/h2>\n\n\n\n<p>\u672c\u5b9e\u9a8c\u4ecd\u7136\u91c7\u7528\u6309\u952e\u70b9\u706f\u7684\u65b9\u5f0f\u8fdb\u884c \u5916\u90e8\u4e2d\u65ad\u7684\u6f14\u793a\uff0c\u8ba9\u6309\u952e\u53bb\u89e6\u53d1\u5916\u90e8\u4e2d\u65ad\u7684\u529f\u80fd\uff0c\u5e76\u4e14\u5728\u4e2d\u65ad\u51fd\u6570\u4e2d\u589e\u52a0\u6539\u53d8\u706f\u72b6\u6001\u7684\u547d\u4ee4\u3002<\/p>\n\n\n\n<p>\u5148\u770b\u539f\u7406\u56fe\uff0c\u7531\u539f\u7406\u56fe\u53ef\u4ee5\u770b\u51fa\u677f\u5b50\u4e0a\u63a5\u4e86\u4e94\u4e2a\u6309\u952e\uff0c\u5e76\u4e14\u9ed8\u8ba4\u662f\u901a\u8fc7\u4e0a\u62c9\u7535\u963b\u4e0a\u62c9\u52303.3V\u7684\uff0c\u4e5f\u5c31\u662f\u5f53\u6309\u952e\u6ca1\u6709\u6309\u4e0b\u7684\u65f6\u5019 \u6309\u952eKEY \u7684\u4fe1\u53f7\u811a\u662f3.3V \uff0c\u5f53\u6309\u952e\u6309\u4e0b\u540e\uff0c\u8be5\u4fe1\u53f7\u811a\u88ab\u62c9\u4f4e\u5230GND\u4e5f\u5c31\u662f0V \u540c\u6837\u4e5f\u80fd\u770b\u51fa \u4e24\u4e2a\u6309\u952e\u5206\u522b\u8fde\u63a5\u5230\u4e86 FPGA\u82af\u7247\u7684 T19 P19 U20 U19 \u548cV20\u4e0a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"463\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/10\/image-111.png\" alt=\"\" class=\"wp-image-1303\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/10\/image-111.png 595w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/10\/image-111-300x233.png 300w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/figure>\n\n\n\n<p>\u4e3a\u4e86\u6309\u952e\u7684\u529f\u80fd\uff0c\u8fd9\u91cc\u518d\u5f15\u5165\u6307\u793a\u706f\uff0c\u8f6c\u63a5\u677f\u4e0a\u4e00\u5171\u67093\u4e2a\u6307\u793a\u706f\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u5c06LED\u7684\u9a71\u52a8\u811a\u62c9\u9ad8\uff0c\u6307\u793a\u706f\u4eae\uff0c\u62c9\u4f4e\u6307\u793a\u706f\u7184\u706d\uff0c\u6307\u793a\u706f\u5206\u522b\u63a5\u5728\u4e3b\u82af\u7247\u7684 H18 K17\u548cE19\u811a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"343\" height=\"704\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/10\/image-113.png\" alt=\"\" class=\"wp-image-1304\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/10\/image-113.png 343w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/10\/image-113-146x300.png 146w\" sizes=\"auto, (max-width: 343px) 100vw, 343px\" \/><\/figure>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">\u5b9e\u9645\u672c\u6b21\u8bd5\u9a8c\u53ea\u7528\u5230\u4e86KEY1\u548cKEY3\u4e24\u4e2a\u6309\u952e\uff0c\u706f\u4e5f\u53ea\u7528\u5230\u4e86LED1\u548cLED2\u4e24\u4e2a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001Vivado\u5de5\u7a0b\u521b\u5efa<\/strong><\/h2>\n\n\n\n<p>\u5de5\u7a0b\u521b\u5efa\u7684\u8fc7\u7a0b\u53ef\u4ee5\u53c2\u8003\u5b9e\u9a8c\u4e00\u4e2d\u7684\u5185\u5bb9\uff0c\u8fd9\u91cc\u4e0d\u8be6\u7ec6\u63cf\u8ff0\u4e86\u3002<a href=\"http:\/\/www.hellofpga.com\/index.php\/2024\/02\/02\/ebaz4205-emio\/\">\u57fa\u4e8eEBAZ4205\u7684PS\u5b9e\u9a8c\u4e00 GPIO\u4e4b\u7528EMIO\u65b9\u5f0f\u70b9\u4eaeLED\uff08\u5b8c\u6574\u56fe\u6587\uff09<\/a>(\u82af\u7247\u578b\u53f7\u9009XC7Z010CLG400-1)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001Vivado \u4e2d\u7684\u8bbe\u7f6e<\/strong><\/h2>\n\n\n\n<p>1\uff09\u5728BLOCK DESIGN \u4e2d\u641c\u7d22\u5e76\u6dfb\u52a0\u4e00\u4e2aZYNQ\u6a21\u5757<\/p>\n\n\n\n<p>2\uff09\u5728ZYNQ \u8bbe\u7f6e\u754c\u9762\uff0c\u8bbe\u7f6eDDR\u7684\u9009\u62e9 MT41K128M16JT \u5e76\u9009\u62e9\u4f4d\u5bbd\u4e3a16bit<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"698\" height=\"217\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-20.png\" alt=\"\" class=\"wp-image-1510\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-20.png 698w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-20-300x93.png 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/figure>\n\n\n\n<p>3) \u6dfb\u52a04\u4e2aEMIO \uff0c\u5176\u4e2d\u4e24\u4e2a\u7528\u6765\u9a71\u52a8LED\u706f\uff0c\u53e6\u4e24\u4e2a\u7528\u6765\u8bfb\u53d6\u6309\u952eKEY\u7684\u4fe1\u606f<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"699\" height=\"292\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-19.png\" alt=\"\" class=\"wp-image-1509\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-19.png 699w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-19-300x125.png 300w\" sizes=\"auto, (max-width: 699px) 100vw, 699px\" \/><\/figure>\n\n\n\n<p>4) \u5bf9GPIO make external\uff0c\u5e76\u4e14\u8fde\u63a5AXI\u7684\u65f6\u949f\uff08AXI\u9ed8\u8ba4\u5f00\u542f\u7684\uff0c\u8fd9\u91cc\u7528\u4e0d\u5230AXI\uff0c\u4e5f\u53ef\u4ee5\u53bb\u8bbe\u7f6e\u91cc\u5173\u95edAXI\u529f\u80fd\uff0c\u5c31\u4e0d\u9700\u8981\u8fde\u63a5\u4e86\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"606\" height=\"267\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-21.png\" alt=\"\" class=\"wp-image-1512\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-21.png 606w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-21-300x132.png 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/figure>\n\n\n\n<p>5) \u4e4b\u540e \u70b9\u9009Create HDL Wrapper<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"397\" height=\"165\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-22.png\" alt=\"\" class=\"wp-image-1513\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-22.png 397w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-22-300x125.png 300w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/figure>\n\n\n\n<p>\u4e4b\u540e\u521b\u5efa\u548c\u6dfb\u52a0\u7ea6\u675f\u6587\u4ef6\uff1a\u53ef\u4ee5\u5728\u56fe\u6587\u754c\u9762\u91cc\u8bbe\u7f6e\u7ba1\u811a\u5b9a\u4e49<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"560\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-29-1024x560.png\" alt=\"\" class=\"wp-image-1573\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-29-1024x560.png 1024w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-29-300x164.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-29-768x420.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-29.png 1240w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u5728\u7ea6\u675f\u6587\u4ef6\u91cc\u6dfb\u52a0\u7ba1\u811a\u5b9a\u4e49\u7684\u63cf\u8ff0<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">set_property PACKAGE_PIN H18 [get_ports {GPIO_0_0_tri_io[3]}]\nset_property PACKAGE_PIN K17 [get_ports {GPIO_0_0_tri_io[2]}]\nset_property PACKAGE_PIN T19 [get_ports {GPIO_0_0_tri_io[1]}]\nset_property PACKAGE_PIN U20 [get_ports {GPIO_0_0_tri_io[0]}]\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[3]}]\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[2]}]\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[1]}]\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[0]}]<\/pre>\n\n\n\n<p>7\uff09\u4e4b\u540e\u5bf9\u7a0b\u5e8f\u8fdb\u884c\u6b63\u5e38\u7684\u7f16\u8bd1\u7efc\u5408\uff0c\u5e76\u4e14\u5bfc\u51fa Export Hardware (\u52fe\u9009 include bitstream)\u4f9bSDK\u52a0\u8f7d<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"460\" height=\"92\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-24.png\" alt=\"\" class=\"wp-image-1515\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-24.png 460w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-24-300x60.png 300w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"318\" height=\"239\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-25.png\" alt=\"\" class=\"wp-image-1516\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-25.png 318w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-25-300x225.png 300w\" sizes=\"auto, (max-width: 318px) 100vw, 318px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u56db\u3001PS\u90e8\u5206\u7a0b\u5e8f\u8bbe\u8ba1\uff1a<\/strong><\/h2>\n\n\n\n<p>\u5728SDK\u73af\u5883\u4e0b\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3aGPIO_INTERRUPT\u7a7a\u7684\u5de5\u7a0b\uff0c\u5e76\u4e14\u6dfb\u52a0main.c \u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include \"xparameters.h\"\n#include \"xgpiops.h\"\n#include \"xscugic.h\"\n#include \"xil_exception.h\"\n#include \"xplatform_info.h\"\n#include &lt;xil_printf.h&gt;\n\n#define LED2    \t57\n#define LED1    \t56\n#define KEY2    \t55\n#define KEY1    \t54\n\n#define GPIO_DEVICE_ID  \tXPAR_XGPIOPS_0_DEVICE_ID\nXGpioPs Gpio;\n#define GPIO_BANK\tXGPIOPS_BANK0  \/* Bank 0 of the GPIO Device *\/\n\n#define GPIO_DEVICE_ID\t\tXPAR_XGPIOPS_0_DEVICE_ID\n#define INTC_DEVICE_ID\t\tXPAR_SCUGIC_SINGLE_DEVICE_ID\n#define GPIO_INTERRUPT_ID\tXPAR_XGPIOPS_0_INTR\n\nstatic XScuGic Intc; \/* The Instance of the Interrupt Controller Driver *\/\n\n\nstatic void IntrHandler(void *CallBackRef, u32 Bank, u32 Status)\n{\n\tXGpioPs *Gpio_cb = (XGpioPs *)CallBackRef;\n\tif (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY1)){\n\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 1);\n\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 0);\n\t\tXGpioPs_IntrClearPin(Gpio_cb, KEY1);\n\t}\n\telse if (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY2)){\n\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 0);\n\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 1);\n\t\tXGpioPs_IntrClearPin(Gpio_cb, KEY2);\n\t}\n}\n\n\n\nvoid SetupInterruptSystem(XScuGic *GicInstancePtr, XGpioPs *Gpio,\n\t\t\t\tu16 GpioIntrId){\n\n\tXScuGic_Config *IntcConfig;\n\tXil_ExceptionInit();\n\n\tIntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);\n\n\tXScuGic_CfgInitialize(GicInstancePtr, IntcConfig,\n\t\t\t\t\tIntcConfig-&gt;CpuBaseAddress);\n\n\tXil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,\n\t\t\t\t(Xil_ExceptionHandler)XScuGic_InterruptHandler,\n\t\t\t\tGicInstancePtr);\n\tXScuGic_Connect(GicInstancePtr, GpioIntrId,\n\t\t\t\t(Xil_ExceptionHandler)IntrHandler,\n\t\t\t\t(void *)Gpio);\n\n\n\tXScuGic_Enable(GicInstancePtr, GpioIntrId);\n\n\tXGpioPs_SetIntrTypePin(Gpio, KEY1,  XGPIOPS_IRQ_TYPE_EDGE_FALLING);\n\tXGpioPs_SetIntrTypePin(Gpio, KEY2,  XGPIOPS_IRQ_TYPE_EDGE_FALLING);\n\t\n\tXGpioPs_IntrEnablePin(Gpio, KEY1);\n\tXGpioPs_IntrEnablePin(Gpio, KEY2);\n\n\tXil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);\n}\n\n\nvoid Gpio_Init(void){\n\tXGpioPs_Config *ConfigPtr;\n\n\tConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);\n\tXGpioPs_CfgInitialize(&amp;Gpio, ConfigPtr,ConfigPtr-&gt;BaseAddr);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, LED1, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, LED1, 1);\n\tXGpioPs_WritePin(&amp;Gpio, LED1, 1);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, LED2, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, LED2, 1);\n\tXGpioPs_WritePin(&amp;Gpio, LED2, 1);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, KEY1, 0);\n\tXGpioPs_SetDirectionPin(&amp;Gpio, KEY2, 0);\n\n\tSetupInterruptSystem(&amp;Intc, &amp;Gpio, GPIO_INTERRUPT_ID);\n}\n\n\n\n\nint main(void)\n{\n\tGpio_Init();\n\n\twhile(1){\n\n\t}\n\n\treturn 0;\n}\n<\/pre>\n\n\n\n<p>\u7a0b\u5e8f\u5f88\u7b80\u5355\uff0c Gpio_Init\u662f\u5bf94\u4e2aGPIO\u8fdb\u884c\u521d\u59cb\u5316\uff0c \u56e0\u4e3aEMIO \u662f\u4ece54\u7684\u7ba1\u811a\u53f7\u5f00\u59cb\u7684\uff0c\u6240\u4ee5\u6839\u636e\u539f\u5148VIVADO \u7684\u7ba1\u811a\u7ea6\u675f\u6765\u770b\uff0c\u4e24\u4e2a\u6309\u952e\u5e94\u8be5\u5bf9\u5e9454\u548c55\uff0c\u4e24\u4e2aLED\u706f\u5bf9\u5e9456\u548c57<\/p>\n\n\n\n<p>SetupInterruptSystem(&amp;Intc, &amp;Gpio, GPIO_INTERRUPT_ID); \u662f\u5bf9\u4e2d\u65ad\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u8fd9\u91cc\u6211\u4eec\u5206\u522b\u5bf9KEY1\u548cKEY2\u90fd\u589e\u52a0\u4e86\u4e2d\u65ad\u521d\u59cb\u5316\uff0c\u8fd9\u4e24\u4e24\u4e2a\u6309\u952e\u4e2d\u4efb\u4f55\u4e00\u4e2a\u6309\u952e\u88ab\u6309\u4e0b \u90fd\u4f1a\u8c03\u7528\u4e2d\u65adXGpioPs_SetIntrTypePin(Gpio, KEY1, XGPIOPS_IRQ_TYPE_EDGE_FALLING);\u4ee3\u8868\u5bf9KEY1\u8bbe\u7f6e\u4e0b\u964d\u6cbf\u4e2d\u65ad\u3002<\/p>\n\n\n\n<p>IntrHandler \u662f\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\uff0c\u5728\u4e2d\u65ad\u4e8b\u4ef6\u4ea7\u751f\u540e\u5bf9\u4e2d\u65ad\u8fdb\u884c\u54cd\u5e94\uff0c\u4e00\u822c\u6211\u4eec\u4e2d\u65ad\u540e\u9700\u8981\u7684\u52a8\u4f5c\u4ee3\u7801\u90fd\u653e\u5728\u8fd9\u4e2a\u51fd\u6570\u91cc\u9762\u3002 \uff08\u56e0\u4e3a\u6211\u4eec\u540c\u65f6\u589e\u52a0\u4e86\u4e24\u4e2a\u5916\u90e8\u4e2d\u65ad\uff0c\u6240\u4ee5\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u8fdb\u6765\u7b2c\u4e00\u4ef6\u4e8b\u662f\u533a\u5206\u54ea\u4e2aGPIO\u4ea7\u751f\u4e86\u4e2d\u65ad\uff0c\u6240\u4ee5\u8fd9\u91cc\u7528XGpioPs_IntrGetStatusPin\u547d\u4ee4\u53bb\u8bfb\u53d6CallBackRef\u7684\u503c\uff0c\u6765\u5224\u65ad\u54ea\u4e2a\u6309\u952e\u4ea7\u751f\u4e86\u4e2d\u65ad\uff0c\u5e76\u6839\u636e\u7ed3\u679c\u70b9\u4eae\u4e0d\u540c\u7684LED\u706f\uff09<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">static void IntrHandler(void *CallBackRef, u32 Bank, u32 Status)\n{\n\tXGpioPs *Gpio_cb = (XGpioPs *)CallBackRef;\n\tif (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY1)){\n\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 1);\n\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 0);\n\t\tXGpioPs_IntrClearPin(Gpio_cb, KEY1);\n\t}\n\telse if (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY2)){\n\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 0);\n\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 1);\n\t\tXGpioPs_IntrClearPin(Gpio_cb, KEY2);\n\t}\n}\n<\/pre>\n\n\n\n<p>\u5bf9\u4e8e\u4e3b\u51fd\u6570main\u51fd\u6570\u6765\u8bf4\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5b8c\u6210GPIO\u521d\u59cb\u5316\uff08\u91cc\u9762\u5305\u62ec\u4e2d\u65ad\u521d\u59cb\u5316\uff09\uff0c\u4e4b\u540e\u5c31\u76f4\u63a5\u4e0d\u4f5c\u4efb\u4f55\u64cd\u4f5c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int main(void)\n{\n\tGpio_Init();\n\twhile(1){\n\n\t}\n\n\treturn 0;\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e94\u3001\u4e0b\u8f7d\u4e0e\u9a8c\u8bc1<\/strong><\/h2>\n\n\n\n<p>1\uff09\u65b0\u521b\u5efa\u7684\u5de5\u7a0b\u6700\u597d\u5148\u5bf9Run as \u8fdb\u884c\u914d\u7f6e\uff1a\u53f3\u952e\u5de5\u7a0b\uff0c\u5e76\u70b9\u9009Run As -&gt; Run Configurations<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"798\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-27.png\" alt=\"\" class=\"wp-image-7494\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-27.png 750w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-27-282x300.png 282w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/figure>\n\n\n\n<p>2\uff09 \u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\u5bf9Reset entire system \u548c Program FPGA\u4e24\u4e2a\u9009\u9879\u8fdb\u884c\u52fe\u9009\u64cd\u4f5c\uff0c\u8fd9\u6837\u5c31\u4e0d\u4f1a\u51fa\u73b0\u4e0b\u8f7d\u7a0b\u5e8fdebug\u7684\u65f6\u5019\u6982\u7387\u6027\u4e0d\u5de5\u4f5c\u7684\u95ee\u9898\u4e86\u3002<strong>\uff08\u8fd9\u6837\u64cd\u4f5c\u540e\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5bf9FPGA\u8fdb\u884c\u914d\u7f6e\uff0c\u4e0d\u9700\u8981\u6309\u4e4b\u524d\u5de5\u7a0b\u624b\u52a8\u5bf9FPGA\u8fdb\u884c\u7f16\u7a0b\u4e86\uff09<\/strong><\/p>\n\n\n\n<p>PS\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u4e0b\u56fe\u5bf9\u8bdd\u6846\uff0c\u53ef\u4ee5\u76f4\u63a5\u53cc\u51fb\u5de6\u4fa7\u7684applicationo \uff08System Debugger\uff09\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"705\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29-1024x705.png\" alt=\"\" class=\"wp-image-7496\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29-1024x705.png 1024w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29-300x206.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29-768x528.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29.png 1401w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>3\uff09\u8bbe\u7f6e\u597d\u4e4b\u540e\uff0c\u9009\u62e9<code>Run As<\/code>&nbsp;-&gt;&nbsp;<code>Launch on Hardware (System Debugger)<\/code>&nbsp;\u8fdb\u884c\u8c03\u8bd5\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"178\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/07\/image-14.png\" alt=\"\" class=\"wp-image-835\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/07\/image-14.png 780w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/07\/image-14-300x68.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/07\/image-14-768x175.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u4e0b\u8f7d\u6210\u529f\u540e\u4f1a\u53d1\u73b0KEY1\u548cKEY3\u4e24\u4e2a\u6309\u952e\u4efb\u610f\u4e00\u4e2a\u88ab\u6309\u4e0b\u5bf9\u5e94\u7684\u706f\u88ab\u70b9\u4eae\uff0c\u8bc1\u660e\u6211\u4eec\u7684\u5916\u90e8\u4e2d\u65ad\u5df2\u6210\u529f\u8fd0\u884c\uff08\u56e0\u4e3a\u4e3b\u7a0b\u5e8f\u4e2d\u5e76\u4e0d\u8d1f\u8d23\u70b9\u706f\uff0c\u53ea\u6709\u5728\u4e2d\u65ad\u4e2d\u624d\u8d1f\u8d23\u6539\u53d8\u706f\u7684\u72b6\u6001\uff09<\/p>\n\n\n\n<p>\u4e2d\u65ad\u6bd4\u8f83\u7b80\u5355\uff0c\u4f46\u662f\u5bf9\u5e94\u7cfb\u7edf\u6027\u7684\u7a0b\u5e8f\u8bbe\u8ba1\u6765\u8bf4\u53c8\u5fc5\u4e0d\u53ef\u5c11\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u672c\u7ae0\u8282\u7684\u5de5\u7a0b\uff1a<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u672c\u6587\u7684\u5b8c\u6574\u5de5\u7a0b\u4e0b\u8f7d:&nbsp;<a href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/22_PS_GPIO_INTERRUPT.zip\">22_PS_GPIO_INTERRUPT<\/a><\/strong><\/li>\n\n\n\n<li><strong>VIVADO\u7684\u7248\u672c\uff1a2018.3<\/strong><\/li>\n\n\n\n<li><strong>\u5de5\u7a0b\u9002\u7528\u4e3b\u677f: EBAZ4205\u4e3b\u677f+\u8f6c\u63a5\u677f<\/strong><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6b21\u5b9e\u9a8c\u5bf9ZYNQ \u7684PS\u7684\u5916\u90e8\u7ba1\u811a\u89e6\u53d1\u4e2d\u65ad\u529f\u80fd\u8fdb\u884c\u6f14\u793a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1566","post","type-post","status-publish","format-standard","hentry","category-ebaz4205"],"views":645,"_links":{"self":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/1566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/comments?post=1566"}],"version-history":[{"count":9,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/1566\/revisions"}],"predecessor-version":[{"id":9918,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/1566\/revisions\/9918"}],"wp:attachment":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/media?parent=1566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/categories?post=1566"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/tags?post=1566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}