{"id":2679,"date":"2023-01-23T14:10:09","date_gmt":"2023-01-23T06:10:09","guid":{"rendered":"http:\/\/www.hellofpga.com\/?p=2679"},"modified":"2023-01-23T14:10:09","modified_gmt":"2023-01-23T06:10:09","slug":"smart-zynq_gpio_in","status":"publish","type":"post","link":"http:\/\/www.hellofpga.com\/index.php\/2023\/01\/23\/smart-zynq_gpio_in\/","title":{"rendered":"Smart ZYNQ\u677f \u5de5\u7a0b\u5341\u4e5d\u00a0 \u57fa\u4e8ePS\u7aef\u7684 GPIO(EMIO)\u8f93\u5165\u529f\u80fd\u6f14\u793a"},"content":{"rendered":"\n<p>\u672c\u6b21\u5b9e\u9a8c\u4e3b\u8981\u6f14\u793aEMIO \u7684GPIO\u8bfb\u53d6\u529f\u80fd<\/p>\n\n\n\n<p>\u672c\u6587\u5728 vivado2018.3\u7248\u672c\u4e0a \u6f14\u793a\uff0c \u5176\u4ed6\u7248\u672c\u8bf7\u81ea\u884c\u7814\u7a76<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u786c\u4ef6\u4ecb\u7ecd<\/h2>\n\n\n\n<p>\u5148\u770b\u539f\u7406\u56fe\uff0c\u7531\u539f\u7406\u56fe\u53ef\u4ee5\u770b\u51fa\u677f\u5b50\u4e0a\u63a5\u4e86\u4e24\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 G17\u548cG18\u7ba1\u811a\u4e0a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"838\" height=\"554\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-95.png\" alt=\"\" class=\"wp-image-2681\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-95.png 838w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-95-300x198.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-95-768x508.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u4e3a\u4e86\u6f14\u793a\u4e24\u4e2a\u6309\u952e\u7684\u529f\u80fd\uff0c\u8fd9\u91cc\u518d\u5f15\u5165\u4e24\u4e2a\u6307\u793a\u706f\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 K16\u548cJ16\u811a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"549\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96.png\" alt=\"\" class=\"wp-image-2682\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96.png 550w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96-300x300.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96-150x150.png 150w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96-100x100.png 100w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u5de5\u7a0b\u521b\u5efa<\/h2>\n\n\n\n<p>\u5b8c\u6574\u7684\u5de5\u7a0b\u521b\u5efa\u56fe\u6587\u6559\u7a0b\u524d\u9762\u5df2\u7ecf\u8be6\u7ec6\u56fe\u6587\u63cf\u5199\u4e86\uff0c\u53ef\u4ee5\u53c2\u8003\u524d\u9762\u7684\u5de5\u7a0b\uff0c\u8fd9\u91cc\u4ec5\u4ec5\u589e\u52a0\u5173\u952e\u6b65\u9aa4\u3002 \u8be6\u7ec6\u8fc7\u7a0b\u53ef\u4ee5\u53c2\u8003<a rel=\"noreferrer noopener\" href=\"http:\/\/www.hellofpga.com\/index.php\/2023\/01\/18\/smart-zynq_emil_test\/\" target=\"_blank\">Smart ZYNQ\u677f \u5de5\u7a0b\u4e03 \u7528ZYNQ\u7684PS\u70b9\u4eae\u8fde\u63a5\u5230PL\u7aef\u7684LED\u706fEMIO \u65b9\u5f0f<\/a><\/p>\n\n\n\n<p>\u5668\u4ef6\u540d\u79f0\u9009\u62e9 xc7z010clg400-1  \u6216 xc7z020clg400-1\uff08xa7z020\uff09 \u4ee5\u5b9e\u9645\u677f\u5b50\u4e0a\u7684\u82af\u7247\u4e3a\u51c6<\/p>\n\n\n\n<p>\u5728BLOCK DESIGN \u4e2d\u641c\u7d22\u5e76\u6dfb\u52a0\u4e00\u4e2aZYNQ\u6a21\u5757<\/p>\n\n\n\n<p>\u5728ZYNQ \u8bbe\u7f6e\u754c\u9762\uff0c\u8bbe\u7f6e DDR MT41K256M16RE-125\u7684\u578b\u53f7 \u548c\u4f4d\u5bbd16bit<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"442\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-92.png\" alt=\"\" class=\"wp-image-2668\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-92.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-92-300x173.png 300w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\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>\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>\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<\/p>\n\n\n\n<p>\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=\"566\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-97-1024x566.png\" alt=\"\" class=\"wp-image-2687\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-97-1024x566.png 1024w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-97-300x166.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-97-768x425.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-97.png 1369w\" 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 K16 [get_ports {GPIO_0_0_tri_io[3]}]\r\nset_property PACKAGE_PIN J16 [get_ports {GPIO_0_0_tri_io[2]}]\r\nset_property PACKAGE_PIN G18 [get_ports {GPIO_0_0_tri_io[1]}]\r\nset_property PACKAGE_PIN G17 [get_ports {GPIO_0_0_tri_io[0]}]\r\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[3]}]\r\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[2]}]\r\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[1]}]\r\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[0]}]<\/pre>\n\n\n\n<p>\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\">\u7a0b\u5e8f\u8bbe\u8ba1\uff1a<\/h2>\n\n\n\n<p>\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3aKEY_TEST\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 \"xstatus.h\"\n#include \"xplatform_info.h\"\n#include \"xscutimer.h\"\n#include \"Xscugic.h\"\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\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\n\n\n\nint main(void)\n{\n\tGpio_Init();\n\n\twhile(1){\n\t\tif(XGpioPs_ReadPin(&amp;Gpio, KEY1)==0){\n\t\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 1);\n\t\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 0);\n\t\t}\n\t\telse if(XGpioPs_ReadPin(&amp;Gpio, KEY2)==0){\n\t\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 0);\n\t\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 1);\n\t\t}\n\t}\n\n\treturn 0;\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<pre class=\"wp-block-preformatted\">#define LED2    \t57\n#define LED1    \t56\n#define KEY2    \t55\n#define KEY1    \t54<\/pre>\n\n\n\n<p>XGpioPs_SetDirectionPin(&amp;Gpio, KEY1, 0); \u6700\u540e\u76840\u4ee3\u8868\u8f93\u5165\uff0cXGpioPs_WritePin(&amp;Gpio, LED1, 1);\u50cf \u8fd9\u4e2a\u6700\u540e\u76841\u5c31\u4ee3\u8868\u8f93\u51fa\u3002<\/p>\n\n\n\n<p>\u4e3b\u7a0b\u5e8f\u4e5f\u975e\u5e38\u7b80\u5355\uff0c \u5bf9GPIO\u521d\u59cb\u5316\u4e4b\u540e \u5c31\u5f00\u59cb\u5faa\u73af\u67e5\u770b\u6309\u952e\u72b6\u6001\uff0c\u5f53\u6309\u952e1\u6309\u4e0b\u65f6LED1\u4eae\uff0cLED2\u7184\u706d\uff0c \u5f53\u6309\u952e2\u6309\u4e0b\u65f6LED2\u4eaeLED1\u7184\u706d\uff08\u4e0a\u7535\u540e\u4e24\u4e2a\u706f\u9ed8\u8ba4\u90fd\u4eae\uff09<\/p>\n\n\n\n<p><strong>\u7a0b\u5e8f\u4ec5\u4f5c\u6f14\u793a\uff0c\u5b9e\u9645\u9879\u76ee\u4e2d\u9700\u8981\u5bf9\u6309\u952e\u589e\u52a0\u6309\u952e\u6d88\u6296\u7a0b\u5e8f\uff0c\u5426\u5219\u6309\u4e0b\u77ac\u95f4\u4f1a\u53cd\u590d\u89e6\u53d1\u7a0b\u5e8f\u4ee3\u7801<\/strong><\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u5b8c\u6574\u5de5\u7a0b\uff08\u4ec5\u4f9b\u5b66\u4e60\u53c2\u8003\uff09<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-983268f3-26af-4768-95fe-4f758f8106b5\" href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/19_PS_KEY_EMIO_TEST_XC7Z010_1.zip\">19_PS_KEY_EMIO_TEST_XC7Z010_1<\/a><a href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/19_PS_KEY_EMIO_TEST_XC7Z010_1.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-983268f3-26af-4768-95fe-4f758f8106b5\">\u4e0b\u8f7d<\/a><\/div>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-8046bec7-585d-441b-8cee-0ce45e5dbf75\" href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/19_PS_KEY_EMIO_TEST_XC7Z010_1-1.zip\">19_PS_KEY_EMIO_TEST_XC7Z010_1<\/a><a href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/19_PS_KEY_EMIO_TEST_XC7Z010_1-1.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-8046bec7-585d-441b-8cee-0ce45e5dbf75\">\u4e0b\u8f7d<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6b21\u5b9e\u9a8c\u4e3b\u8981\u6f14\u793aEMIO \u7684GPIO\u8bfb\u53d6\u529f\u80fd<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-2679","post","type-post","status-publish","format-standard","hentry","category-smart-zynq-board"],"views":822,"_links":{"self":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/2679","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=2679"}],"version-history":[{"count":8,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/2679\/revisions"}],"predecessor-version":[{"id":2695,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/2679\/revisions\/2695"}],"wp:attachment":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/media?parent=2679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/categories?post=2679"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/tags?post=2679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}