{"id":309,"date":"2021-08-19T23:02:42","date_gmt":"2021-08-19T15:02:42","guid":{"rendered":"http:\/\/www.hellofpga.com\/?p=309"},"modified":"2024-02-03T22:46:05","modified_gmt":"2024-02-03T14:46:05","slug":"zynq_ps_spi_lcd","status":"publish","type":"post","link":"http:\/\/www.hellofpga.com\/index.php\/2021\/08\/19\/zynq_ps_spi_lcd\/","title":{"rendered":"EBAZ4205 \u7b2c\u5341\u4e09\u4e2a\u5de5\u7a0b \u7528zynq\u7684PS\u8d44\u6e90\u9a71\u52a8SPI\u5f69\u8272LCD\uff08\u786c\u4ef6SPI\u65b9\u6848 \u7d2b\u8272\u677f\u5b50\uff09"},"content":{"rendered":"\n<p>\u8f6c\u63a5\u677f\u4e0a\u81ea\u5e26\u4e86\u4e00\u5757LCD \u5c4f\u5e55\uff0c\u53d7IO\u8d44\u6e90\u9650\u5236\uff0c\u5c4f\u5e55\u7684\u63a5\u53e3\u4f7f\u7528\u4e86\u5360\u7528\u7ebf\u5e8f\u6bd4\u8f83\u5c11\u7684SPI\u63a5\u53e3\uff0c\u672c\u6587\u5c06\u901a\u8fc7ZYNQ\u7684PS\u8d44\u6e90\u53bb\u70b9\u4eae\u8fd9\u4e2a\u6db2\u6676\u5c4f\u5e55<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color has-medium-font-size\"><strong>\u4e4b\u524dZYNQ\u548c\u7d2b\u8272\u677f\u5b50\u786c\u4ef6SPI \u5b58\u5728\u7684\u517c\u5bb9\u6027\u95ee\u9898\u5df2\u7ecf\u89e3\u51b3\uff0c\u4ee5\u4e0b\u5de5\u7a0b\u53ef\u4ee5\u76f4\u63a5\u8c03\u8bd5\u4f7f\u7528<\/strong> <strong>20220504<\/strong><\/p>\n\n\n\n<p class=\"has-black-color has-text-color\"><strong>\u7531<s>\u4e8e\u6269\u5c55\u677f\u4e0a\u7684CS\u811a\u5e76\u672a\u5f15\u51fa\uff08\u5c4f\u5e55\u5382\u5bb6\u4e4b\u524d\u7684demo\u6ca1\u6709\u5f15\u51fa\uff09 \uff0c\u5bfc\u81f4\u548cZYNQ \u786c\u4ef6SPI\u6709\u4e9b\u51b2\u7a81\uff0c\u957f\u65f6\u95f4\u5f85\u673aSPI\u72b6\u6001\u4e0b\uff0c \u5c4f\u5e55\u4f1a\u51fa\u73b0\u6b7b\u673a\u4e0d\u80fd\u64cd\u4f5c\u7684\u60c5\u51b5\uff0c\u6000\u7591\u662f\u548cZYNQ \u91ca\u653e\u4e86SPI\u603b\u7ebf\u6709\u5173\uff0c\u6240\u4ee5\u540e\u9762\u70b9\u4eae\u5c4f\u5e55\u6539\u6210\u7528IO\u6a21\u62df\u7684\u65b9\u5f0f\u53bb\u70b9\u4eae\u5c4f\u5e55\uff0c \u5177\u4f53\u5185\u5bb9\u53ef\u4ee5\u770b\u7b2c\u5341\u4e2a\u5de5\u7a0b<\/s><\/strong><s>http:\/\/www.hellofpga.com\/index.php\/2022\/03\/08\/ps_lcd_io_spi\/<\/s><\/p>\n\n\n\n<p>\u53e6\u5916\u7f51\u7ad9\u91cc\u8fd8\u63d0\u4f9b\u4e86GPIO\u6a21\u62dfSPI\u70b9\u5c4f\u7684\u4f8b\u7a0b\u5e8f\uff0c\u5728\u7b2c\u5341\u4e8c\u4e2a\u5de5\u7a0b<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u786c\u4ef6\u4ecb\u7ecd<\/h2>\n\n\n\n<p>\u8f6c\u63a5\u677f\u90e8\u5206\u786c\u4ef6LCD \u63a5\u53e3\u5982\u4e0b\u56fe\u6240\u793a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"291\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-59-1024x291.png\" alt=\"\" class=\"wp-image-310\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-59-1024x291.png 1024w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-59-300x85.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-59-768x218.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-59.png 1452w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>BL  \u8d1f\u8d23\u63a7\u5236\u80cc\u5149\uff0c\u9ad8\uff1a\u5c4f\u5e55\u70b9\u4eae\uff0c \u4f4e\uff1a\u5c4f\u5e55\u7184\u706d<\/p>\n\n\n\n<p>SCL   \u65f6\u949f<\/p>\n\n\n\n<p>SDA    \u6570\u636e<\/p>\n\n\n\n<p>D\/C    \u6570\u636e\/\u547d\u4ee4\u6307\u793a<\/p>\n\n\n\n<p>RES   \u5c4f\u5e55\u590d\u4f4d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u9a71\u52a8\u601d\u8def<\/h2>\n\n\n\n<p>\u5c4f\u5e55\u672c\u8eab\u662f\u8fde\u63a5\u5230ZYNQ\u7684PL\u8d44\u6e90\u4e0a\uff0c\u70b9\u4eae\u5c4f\u5e55\u53ef\u4ee5\u7528\u7eaffpga\u53bb\u9a71\u52a8SPI\u7684\u65b9\u5f0f\u70b9\u4eae\uff0c\u4e5f\u53ef\u4ee5\u7528PS\u8d44\u6e90\u53bb\u70b9\u4eae\uff0c\u4e3a\u4e86\u65b9\u4fbf\u6f14\u793a\uff0c\u8fd9\u91cc\u91c7\u7528PS\u8d44\u6e90\u53bb\u5b9e\u73b0<\/p>\n\n\n\n<p>\u901a\u8fc7EMIO\u7684\u65b9\u5f0f \u5c06PS\u90e8\u5206\u786c\u4ef6SPI\u8d44\u6e90\u6620\u5c04\u5230 ZYNQ\u7684PL\u53e3\u4e0a\u53bb\u70b9\u4eae\u5c4f\u5e55<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3.\u521b\u5efa\u5de5\u7a0b<\/h2>\n\n\n\n<p>1\uff09\u65b0\u5efa\u4e00\u4e2a\u9879\u76ee\uff0c\u82af\u7247\u578b\u53f7\u9009\u62e9 XC7Z010CLG400-1<\/p>\n\n\n\n<p>2) \u521b\u5efa\u4e00\u4e2aBLOCK\u8bbe\u8ba1\uff0c\u5e76\u6dfb\u52a0ZYNQ7 PROCESSING SYSTEM\u6a21\u5757\uff0c\u8f6f\u4ef6\u81ea\u52a8\u751f\u6210\u4e86\u4e00\u4e2a zynq\u7684block \u5982\u4e0b\u56fe\u6240\u793a\uff0c\u63a5\u4e0b\u6765\u8981\u505a\u4e00\u4e9b\u76f8\u5e94\u7684\u8bbe\u7f6e\uff0c\u53cc\u51fb\u4e0b\u56fe\u4e2d\u7684ZYNQ\u6838<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-3.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>3\uff09\u5728ZYNQ\u4e2d\u8bbe\u7f6e\u65f6\u949f\u529f\u80fd\uff1a<\/p>\n\n\n\n<p>\u627e\u5230 \u8bbe\u7f6e\u9879\u76ee\u4e2d\u7684 Clock Configuration \u9009\u9879\uff0c \u5728PL Fabric Clocks \u8bbe\u7f6e\u81ea\u5df1\u9700\u8981\u7684\u65f6\u949f\u9891\u7387\uff0c\u8fd9\u91cc\u4e00\u5171\u67094\u79cd\u9891\u7387\u53ef\u4ee5\u8bbe\u7f6e \u7c7b\u4f3c\u4e8e\u6211\u4eec\u7684PLL\u529f\u80fd\u3002\u8fd9\u91cc\u6211\u4eec\u8bbe\u7f6e50M\u65f6\u949f<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"583\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-50.png\" alt=\"\" class=\"wp-image-264\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-50.png 960w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-50-300x182.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-50-768x466.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>4\uff09\u5728zynq\u4e2d\u8bbe\u7f6eDDR\u529f\u80fd\uff1a<\/p>\n\n\n\n<p>\u4f9d\u6b21\u5728\u5f39\u7a97\u91cc\u627e\u5230DDR Configuration\u2192DDR Controller Configuration\u2192DDR3\uff0c\u5728Memory Part\u4e0b\u62c9\u83dc\u5355\u4e2d\u6839\u636e\u81ea\u5df1\u677f\u5b50\u4e0a\u7684DDR\u6765\u9009\u62e9\u76f8\u5e94\u7684DDR3\uff0c\u672c\u5b9e\u9a8c\u6240\u7528\u5230\u578b\u53f7\uff1aMT41K128M16JT 125\uff0c\u6570\u636e\u4f4d\u5bbd\u9009\u62e916bit \u6700\u540e\u70b9\u51fb\u201cOK\u201d,\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"977\" height=\"493\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-5.png\" alt=\"\" class=\"wp-image-188\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-5.png 977w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-5-300x151.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-5-768x388.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>5)\u5728ZYNQ\u4e2d\u914d\u7f6eSPI\u529f\u80fd<\/p>\n\n\n\n<p>\u56e0\u4e3a\u5c4f\u5e55\u7684\u63a5\u53e3\u662f\u8fde\u63a5\u5230ZYNQ\u7684PL\u53e3\u4e0a\uff0c\u6240\u4ee5\u8fd9\u91cc\u6211\u4eec\u8c03\u7528EMIO\u7684SPI\u529f\u80fd\uff08\u5373\u4f7f\u7528PS\u7684SPI\u529f\u80fd\uff0c\u4f46\u662f\u5185\u90e8\u8fde\u63a5\u6620\u5c04\u5230PL\u7684GPIO\u53e3\u4e0a\uff09<\/p>\n\n\n\n<p>&nbsp;MIO Configuration\u2192SPI 0\u52fe\u4e0a   \u5e76\u9009\u62e9EMIO<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"787\" height=\"564\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-60.png\" alt=\"\" class=\"wp-image-313\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-60.png 787w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-60-300x215.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-60-768x550.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>6\uff09\u7531\u4e8e\u5c4f\u5e55\u7684\u9a71\u52a8\u9664\u4e86SPI\u5916\uff0c\u8fd8\u9700\u89813\u4e2a\u989d\u5916\u7684GPIO\u53e3\u6765\u5206\u522b\u63a7\u5236\u80cc\u5149BL \uff0c\u590d\u4f4dRES\u548c D\/C\u4fe1\u53f7\uff0c\u6240\u4ee5\u8fd9\u91cc\u589e\u52a0\u4e09\u4e2aGPIO\u53e3\uff0c\u8fd9\u91ccGPIO\u8d44\u6e90\u9009\u62e9EMIO GPIO   \u4f4d\u5bbdWidth\u9009\u62e93\uff08\u56e0\u4e3a\u662f3\u4e2aIO\u53e3\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"345\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-63.png\" alt=\"\" class=\"wp-image-317\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-63.png 764w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-63-300x135.png 300w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>5\uff09\u5b8c\u6210\u4e0a\u8ff0\u64cd\u4f5c\u540e\uff0c \u70b9\u51fb\u201cRun Block Automation\u201d\u5982\u4e0b\u56fe\u6240\u793a\u3002\u5728\u5f39\u51fa\u7684\u9009\u9879\u4e2d\u4fdd\u6301\u9ed8\u8ba4\uff0c\u70b9\u51fb\u201cOK\u201d\uff0c\u5373\u53ef\u5b8c\u6210\u5bf9ZYNQ7 Processing System\u7684\u914d\u7f6e\uff0c\u5e76\u7528\u9f20\u6807\u8fde\u63a5FCLK_CLK\u548c M_AXI_GP0_ACLK\uff0c\u5f97\u5230\u4e0b\u56fe<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"577\" height=\"265\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-64.png\" alt=\"\" class=\"wp-image-318\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-64.png 577w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-64-300x138.png 300w\" sizes=\"auto, (max-width: 577px) 100vw, 577px\" \/><\/figure>\n\n\n\n<p>\u5728\u4e0a\u56fe\u4e2d\u5206\u522b\u70b9\u51fbIO\u53e3\u8fdb\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<p>\u53f3\u952eGPIO_0\u9009\u62e9Make External<\/p>\n\n\n\n<p>\u53f3\u952eSPI_0 \u9009\u62e9Make External<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"385\" height=\"350\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-65.png\" alt=\"\" class=\"wp-image-319\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-65.png 385w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-65-300x273.png 300w\" sizes=\"auto, (max-width: 385px) 100vw, 385px\" \/><\/figure>\n\n\n\n<p>6\uff09source\u2192Design Source \uff0c\u53f3\u952e\u6211\u4eec\u521b\u5efa\u7684BLOCK\u5de5\u7a0b\uff0c\u70b9\u51fbcreate HDL wrapper\uff0c\u6253\u5305BLOCK\u6587\u4ef6\u5e76\u751f\u6210.v\u4ee3\u7801<\/p>\n\n\n\n<p>\u8fd9\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u8f6f\u4ef6\u7684TOP\u5c42 \u7684verilog\u6587\u4ef6,\u6253\u5f00\u540e\u89c2\u5bdf\u7ba1\u811a\u4fe1\u53f7,\u5982\u4e0b\u56fe<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"257\" height=\"244\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-66.png\" alt=\"\" class=\"wp-image-320\"\/><figcaption class=\"wp-element-caption\">]<\/figcaption><\/figure>\n\n\n\n<p>\u5708\u5185\u7684\u51e0\u4e2a\u7ba1\u811a\u662f\u6211\u4eec\u4e4b\u524d\u5b9a\u4e49\u7684SPI \u7ba1\u811a,\u548cGPIO\u7ba1\u811a,  \u5176\u4e2d <\/p>\n\n\n\n<p>\u5176\u4e2dspi_0_io0\u4e3a SPI\u7684MISO\u4fe1\u53f7,  spi_0_io1_io \u4e3aMOSI\u4fe1\u53f7  ,SCK \u4e3aSPI\u65f6\u949f\u4fe1\u53f7,  SS,SS1,SS2\u5206\u522b\u4e3a\u4e09\u7ec4SPI \u7684SN\u4fe1\u53f7<\/p>\n\n\n\n<p>GPIO_0_0\u4e3a\u521a\u624d\u5b9a\u4e49\u7684\u4e09\u4e2aGPIO (\u63a7\u5236\u5c4f\u5e55\u7684\u80cc\u5149, \u590d\u4f4d \u548cD\/C\u7528)<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>7)  \u7cbe\u7b80\u5c4f\u5e55\u6ca1\u7528\u5230\u7684SPI\u7ba1\u811a(\u5c4f\u5e55\u591a\u6570SPI\u7ba1\u811a\u5e76\u6ca1\u6709\u4f7f\u7528\u5230)<\/p>\n\n\n\n<p>\u5c4f\u5e55\u5b9e\u9645\u53ea\u7528\u5230\u4e86 SPI\u7684\u6570\u636eSDA\u548c\u65f6\u949fSCL\u4e24\u4e2a\u4fe1\u53f7, \u6240\u4ee5SPI \u6211\u4eec\u53ea\u9700\u8981\u5f15\u51fa MOSI (SDA) \u548c SCK(SCL)\u5373\u53ef<\/p>\n\n\n\n<p>\u5220\u9664\u5982\u4e0b\u6846\u56fe\u4e2d\u7684\u4fe1\u53f7\u7684\u4f4d\u7f6e   (\u8f93\u5165\u8f93\u51fa\u5b9a\u4e49,\u4ee5\u53ca\u6a21\u5757\u7684\u4fe1\u53f7\u5b9a\u4e49\u4e24\u5904)  ,\u6700\u540e\u4e00\u884c\u4fdd\u7559 &#8220;);&#8221; \u5bb9\u6613\u500d\u8bef\u5220<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"283\" height=\"186\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-67-1.png\" alt=\"\" class=\"wp-image-354\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"314\" height=\"238\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-68-1.png\" alt=\"\" class=\"wp-image-355\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-68-1.png 314w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-68-1-300x227.png 300w\" sizes=\"auto, (max-width: 314px) 100vw, 314px\" \/><\/figure>\n\n\n\n<p>\u540c\u6837\u4e5f\u9700\u8981\u5220\u9664\u4e24\u4e2a\u5185\u90e8 buf(\u5426\u5219 \u5916\u90e8\u7ba1\u811a\u4e0d\u8c03\u7528\u4f1a\u62a5\u9519)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"251\" height=\"444\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-82.png\" alt=\"\" class=\"wp-image-357\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-82.png 251w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-82-170x300.png 170w\" sizes=\"auto, (max-width: 251px) 100vw, 251px\" \/><\/figure>\n\n\n\n<p>8) \u70b9\u51fb\u7eff\u8272\u7bad\u5934RUN \u5bf9\u4ee3\u7801\u8fdb\u884c\u7f16\u8bd1<\/p>\n\n\n\n<p>9) \u70b9\u51fbRTL \u4e2d\u7684SCHEMATIC , \u5e76\u9009\u62e9\u53f3\u8fb9\u51fa\u73b0\u7684 IO Ports \u6765\u589e\u52a0SPI\u7684\u7ba1\u811a\u5b9a\u4e49(\u8fd9\u4e00\u6b65\u4e5f\u53ef\u4ee5\u5728\u7ea6\u675f\u6587\u4ef6\u4e2d\u5b9a\u4e49, \u53ef\u770b\u4e4b\u524d\u7684\u4f8b\u5b50)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"411\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-69-1024x411.png\" alt=\"\" class=\"wp-image-324\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-69-1024x411.png 1024w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-69-300x120.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-69-768x308.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-69.png 1436w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u4fee\u6539GPIO \u7ba1\u811a\u5b9a\u4e49  \u548cSPI\u7ba1\u811a\u5b9a\u4e49,\u5982\u4e0b\u56fe\u6240\u793a  ,\u4fee\u6539\u540e\u4fdd\u5b58(\u5982\u5f39\u51fa \u7a97\u53e3\u9700\u8981,\u5219\u5728\u7a97\u53e3\u4e2d\u8f93\u5165\u7ea6\u675f\u6587\u4ef6\u540d,\u7136\u540e\u4fdd\u5b58)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"990\" height=\"223\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-83.png\" alt=\"\" class=\"wp-image-358\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-83.png 990w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-83-300x68.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-83-768x173.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>BL    T20<\/p>\n\n\n\n<p>D\/C    R18<\/p>\n\n\n\n<p>SCL    R19<\/p>\n\n\n\n<p>SDA    P20<\/p>\n\n\n\n<p>RES    N17<\/p>\n\n\n\n<p>10) \u751f\u6210bit\u6587\u4ef6 :\u6309\u4e0bGenerate Bitstream \u5b8c\u6210\u7efc\u5408\u4ee5\u53ca\u751f\u6210bit\u6587\u4ef6<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"303\" height=\"203\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-18.png\" alt=\"\" class=\"wp-image-204\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-18.png 303w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-18-300x201.png 300w\" sizes=\"auto, (max-width: 303px) 100vw, 303px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">5.SDK\u7a0b\u5e8f\u7f16\u5199<\/h2>\n\n\n\n<p>1\uff09File\u2192Export\u2192Export hardware\u2026\uff0c\u5728\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u4e2d\u52fe\u9009\u201cinclude bitstream\u201d\uff0c\u70b9\u51fb\u201cOK\u201d\u786e\u8ba4\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"462\" height=\"541\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-20.png\" alt=\"\" class=\"wp-image-207\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-20.png 462w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-20-256x300.png 256w\" sizes=\"auto, (max-width: 462px) 100vw, 462px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"332\" height=\"252\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-24.png\" alt=\"\" class=\"wp-image-211\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-24.png 332w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-24-300x228.png 300w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><\/figure>\n\n\n\n<p>2\uff09File\u2192Lauch SDK\uff0c\u5728\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u4e2d\uff0c\u4fdd\u5b58\u9ed8\u8ba4\uff0c\u70b9\u51fb\u201cOK\u201d\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"361\" height=\"285\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-21.png\" alt=\"\" class=\"wp-image-212\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-21.png 361w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-21-300x237.png 300w\" sizes=\"auto, (max-width: 361px) 100vw, 361px\" \/><\/figure>\n\n\n\n<p>\u7cfb\u7edf\u5c06\u81ea\u52a8\u6253\u5f00SDK\u5f00\u53d1\u73af\u5883<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"998\" height=\"748\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-22.png\" alt=\"\" class=\"wp-image-213\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-22.png 998w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-22-300x225.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-22-768x576.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>3\uff09\u65b0\u5efa\u4e00\u4e2a\u5de5\u7a0b file\u2192new\u2192Application Project\uff0c\u6765\u65b0\u5efa\u4e00\u4e2a\u201cApplication Project\u201d\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"546\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-23.png\" alt=\"\" class=\"wp-image-214\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-23.png 624w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-23-300x263.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>4\uff09\u5728\u65b0\u5efa\u5de5\u7a0b\u540d\u4e2d\u8f93\u5165\u81ea\u5df1\u7684\u5de5\u7a0b\u540d\u79f0\uff0c\u70b9\u51fbNEXT<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"502\" height=\"251\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-75.png\" alt=\"\" class=\"wp-image-332\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-75.png 502w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-75-300x150.png 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/figure>\n\n\n\n<p>5)\u9009\u62e9\u4e00\u4e2a\u7a7a\u5de5\u7a0b,\u70b9\u51fb\u5b8c\u6210<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"421\" height=\"194\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-73.png\" alt=\"\" class=\"wp-image-330\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-73.png 421w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-73-300x138.png 300w\" sizes=\"auto, (max-width: 421px) 100vw, 421px\" \/><\/figure>\n\n\n\n<p>6) \u5728\u7a7a\u5de5\u7a0b\u4e2d\u521b\u5efa\u6211\u4eec\u81ea\u5df1\u7684\u4ee3\u7801<\/p>\n\n\n\n<p>\u5c55\u5f00\u6211\u4eec\u521b\u5efa\u7684\u5de5\u7a0b,\u5728src\u76ee\u5f55\u4e0a\u53f3\u952e\uff0c\u9009\u62e9New-&gt;Source File\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"362\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-76.png\" alt=\"\" class=\"wp-image-333\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-76.png 640w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-76-300x170.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p>\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\u521b\u5efa\u4e00\u4e2amain.c\u6587\u4ef6<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"528\" height=\"422\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-77.png\" alt=\"\" class=\"wp-image-334\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-77.png 528w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-77-300x240.png 300w\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>6\uff09\u4e66\u5199\u81ea\u5df1\u7684\u4ee3\u7801<\/p>\n\n\n\n<p>6.1<strong>\u5c0f\u8d34\u58eb\uff1a<\/strong><\/p>\n\n\n\n<p>\u5728\u521d\u6b21\u5199PS\u90e8\u5206\u7684\u4ee3\u7801\u65f6\uff0c\u5982GPIO\u4ee3\u7801 \u548cSPI\u4ee3\u7801\uff0c\u4e0d\u77e5\u9053\u600e\u4e48\u5199\u7684\u60c5\u51b5\u4e0b\uff0c\u5176\u5b9e\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00 BSP\u5de5\u7a0b\u4e0b\u7684 system.mss\u6587\u4ef6\uff0c \u7136\u540e\u5728\u53f3\u8fb9\u5bfc\u5165\u9700\u8981\u7684\u53c2\u8003\u4f8b\u7a0b\uff0c \u7136\u540e\u5c06\u4f8b\u7a0b\u4e2d\u81ea\u5df1\u9700\u8981\u7684\u90e8\u5206\uff08\u5982GPIO\u521d\u59cb\u5316\uff0c\u6216\u8005SPI\u7684\u5199\u548c\u8bfb\u4ee3\u7801COPY\u5230\u81ea\u5df1\u5de5\u7a0b\u7684main\u51fd\u6570\u4e2d\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"528\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-78-1024x528.png\" alt=\"\" class=\"wp-image-341\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-78-1024x528.png 1024w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-78-300x155.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-78-768x396.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-78.png 1149w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>6.2\u5b9a\u4e49GPIO\u90e8\u5206<\/p>\n\n\n\n<p>\u4e0b\u9762\u8fdb\u5165\u6b63\u9898\uff0c \u6211\u4eec\u8981\u70b9\u4eae\u5c4f\u5e55\uff0c \u5c4f\u5e55\u8fd9\u91cc\u7528\u4e863\u4e2aGPIO \u90fd\u662f\u7528\u4e86ZYNQ PS\u7aef\u7684EMIO\u8d44\u6e90\uff0c EMIO\u7684GPIO\u8d44\u6e90\u662f\u4ece54\u5f00\u59cb\u7684\uff0c \u6240\u4ee5\u6211\u4eec\u6839\u636eFPGA\u7ba1\u811a\u7ea6\u675f\u4e2d\u7684 GPIO 0-3 \u5206\u522b\u5bf9\u5e94 EMIO\u768454-55-56\uff0c\u5982\u4e0b\u56fe\u5bf9GPIO\u8fdb\u884c\u5b9a\u4e49<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#define EMIO_LCD_BL    \t54\n#define EMIO_LCD_CD  \t55\n#define EMIO_LCD_RES \t56<\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765 \u7b80\u5355\u4ecb\u7ecd\u4e0bGPIO\u7684\u8c03\u7528<\/p>\n\n\n\n<p>a. GPIO\u7684\u521d\u59cb\u5316<\/p>\n\n\n\n<p>\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u9700\u8981\u5148\u5b9a\u4e49\u4e00\u4e2aXgpioPs \u7684\u7ed3\u6784\u4f53\u6307\u9488\uff0c \u8fd9\u4e2a\u6307\u9488\u7684\u5185\u5bb9\u5305\u62ecgpio\u5206\u914d\u7684ID\u548c\u57fa\u5730\u5740\uff0c\u8fd9\u4e9b\u4fe1\u606f\u901a\u5e38\u5728xparameter.h\u5934\u6587\u4ef6\u4e2d\uff0c \u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528XGpioPs_LookupConfig\u51fd\u6570\uff0c\u5b83\u80fd\u591f\u5728\u914d\u7f6e\u4fe1\u606f\u4e2d\u627e\u5230\u5bf9\u5e94ID\u7684\u914d\u7f6e\u4fe1\u606f<\/p>\n\n\n\n<p> ConfigPtr=XGpioPs_LookupConfig(GPIO_DEVICE_ID); \u5c31\u76f8\u5f53\u4e8e\u628a\u83b7\u5f97\u5230\u7684\u4fe1\u606f\u8d4b\u4e88\u7ed9\u4e4b\u524d\u5b9a\u4e49\u7684ConfigPtr\u7ed3\u6784\u4f53<\/p>\n\n\n\n<p>\u6700\u7ec8\u518d\u7528 XGpioPs_CfgInitialize \u51fd\u6570\u6765\u521d\u59cb\u5316GPIO<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void Lcd_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, EMIO_LCD_BL, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, EMIO_LCD_BL, 1);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, EMIO_LCD_CD, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, EMIO_LCD_CD, 1);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, EMIO_LCD_RES, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, EMIO_LCD_RES, 1);\n\n\tXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_BL, 0);\n\tXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_CD, 0);\n\tXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_RES, 0);\n}<\/pre>\n\n\n\n<p>b.GPIO\u7684\u4f7f\u7528 \uff08EMIO_LCD_BL\u4e3a\u4e4b\u524d\u5b9a\u4e49\u7684 EMIO 54 \u7684\u7ba1\u811a\uff09<\/p>\n\n\n\n<p>XGpioPs_SetDirectionPin(&amp;Gpio, EMIO_LCD_BL, 1);\/\/\u8bbe\u7f6e\u6210\u8f93\u51fa\u6a21\u5f0f    <br>XGpioPs_SetOutputEnablePin(&amp;Gpio, EMIO_LCD_BL, 1);\/\/\u6253\u5f00\u8f93\u51fa\u4f7f\u80fd<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>XGpioPs_WritePin(&amp;Gpio, EMIO_LCD_BL, 0);\/\/ 0\u7f6e\u4f4e\nXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_BL, 1);\/\/ 1\u62c9\u9ad8\n\n<\/code><\/pre>\n\n\n\n<p>6.3 SPI\u90e8\u5206\u7684\u5b9a\u4e49 \uff0c\u548cGPIO\u7c7b\u4f3c  SPI\u4e5f\u6709\u521d\u59cb\u5316\u548c\u4f7f\u7528\u4e24\u90e8\u5206<\/p>\n\n\n\n<p>a.SPI\u7684\u521d\u59cb\u5316  \u548cGPIO\u7c7b\u4f3c\uff0c\u4e5f\u662f\u5b9a\u4e49\u4e86\u4e00\u4e2a\u7ed3\u6784\u4f53\uff0c\u4e5f\u540c\u6837\u901a\u8fc7 LookupConfig \u6765\u83b7\u5f97\u5bf9\u5e94\u7684\u786c\u4ef6\u914d\u7f6e\u4fe1\u606f\uff0c \u6700\u7ec8\u7528 XSpiPs_CfgInitialize\u6765\u5b8c\u6210\u521d\u59cb\u5316\uff0c\u503c\u5f97\u6ce8\u610f\u7684\u662f\u7a0b\u5e8f\u5f53\u4e2d XSpiPs_SetClkPrescaler \u51fd\u6570\u662f\u7528\u6765\u4e3aSPI\u529f\u80fd\u63d0\u4f9b\u4e3b\u65f6\u949f\u7684\u5206\u9891\u7528\u7684\uff0c\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u9700\u8981\u7684\u901f\u7387\u9009\u62e9\u5206\u9891\u53c2\u6570<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void Lcd_Spi_Init(){\n   XSpiPs_Config *SpiConfig;\n   SpiConfig = XSpiPs_LookupConfig(SPI_DEVICE_ID);\n   XSpiPs_CfgInitialize(&amp;SpiInstance, SpiConfig,\n\t\t\tSpiConfig-&gt;BaseAddress);\n\n   XSpiPs_SetOptions(&amp;SpiInstance, XSPIPS_MASTER_OPTION |\n\t\t\t\t   XSPIPS_FORCE_SSELECT_OPTION);\n   XSpiPs_SetClkPrescaler(&amp;SpiInstance,XSPIPS_CLK_PRESCALE_128);\n}<\/pre>\n\n\n\n<p>b.\u4f20\u8f93   \u4f20\u8f93\u662f\u7528 XSpiPs_PolledTransfer \u51fd\u6570\u8fdb\u884c\u7684\uff0c \u5176\u4e2d SendBufPtr \u662f\u53d1\u9001\u7684\u6570\u636e\uff0c RecvBufPtr \u662f\u63a5\u53d7\u7684\u6570\u636e\uff0c ByteCount \u53ef\u4ee5\u5b9a\u4e49\u6211\u4eec\u7684SPI \u662f8\u4f4d 16\u4f4d\u6216\u800532\u4f4d\uff0c\u4e0b\u9762\u662f\u8fd9\u4e2a\u51fd\u6570\u7684\u5b9a\u4e49<\/p>\n\n\n\n<p>s32 XSpiPs_PolledTransfer(XSpiPs *InstancePtr, u8 *SendBufPtr,<br>u8 *RecvBufPtr, u32 ByteCount)<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>7\uff09\u4e0a\u9762\u7b80\u5355\u4ecb\u7ecd\u4e86PS\u90e8\u5206\u7684GPIO\u548c\uff0cSPI\u529f\u80fd\uff0c\u63a5\u4e0b\u6765\u5728main.c\u4e2d \u5b8c\u5584\u5c4f\u5e55\u7684\u4ee3\u7801\uff0c \u5c06\u4e0b\u9762\u7684\u5b8c\u6574\u4ee3\u7801\u590d\u5236\u5230\u5de5\u7a0b\u4e2d<\/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 \"xspips.h\"\n\n#include &lt;xil_printf.h&gt;\n\n#define WHITE         \t 0xFFFF\n#define BLACK         \t 0x0000\n#define BLUE         \t 0x001F\n#define BRED             0XF81F\n#define GRED \t\t \t 0XFFE0\n#define GBLUE\t\t \t 0X07FF\n#define RED           \t 0xF800\n#define MAGENTA       \t 0xF81F\n#define GREEN         \t 0x07E0\n#define CYAN          \t 0x7FFF\n#define YELLOW        \t 0xFFE0\n#define BROWN \t         0XBC40\n#define BRRED \t\t \t 0XFC07\n#define GRAY  \t\t \t 0X8430\n\n#define EMIO_LCD_BL    \t54\n#define EMIO_LCD_CD  \t55\n#define EMIO_LCD_RES \t56\n\n\n#define GPIO_DEVICE_ID  \tXPAR_XGPIOPS_0_DEVICE_ID\n#define SPI_DEVICE_ID\t\tXPAR_XSPIPS_0_DEVICE_ID\n\nXGpioPs Gpio;\t\/* The driver instance for GPIO Device. *\/\nstatic XSpiPs SpiInstance;\n\n\nvoid Lcd_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, EMIO_LCD_BL, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, EMIO_LCD_BL, 1);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, EMIO_LCD_CD, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, EMIO_LCD_CD, 1);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, EMIO_LCD_RES, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, EMIO_LCD_RES, 1);\n\n\tXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_BL, 0);\n\tXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_CD, 0);\n\tXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_RES, 0);\n}\n\n\nvoid Lcd_Spi_Init(){\n\tXSpiPs_Config *SpiConfig;\n\n\tSpiConfig = XSpiPs_LookupConfig(SPI_DEVICE_ID);\n\tXSpiPs_CfgInitialize(&amp;SpiInstance, SpiConfig,\n\t\t\tSpiConfig-&gt;BaseAddress);\n\n\tXSpiPs_SetOptions(&amp;SpiInstance, XSPIPS_MASTER_OPTION|\n\t\t\tXSPIPS_CLK_ACTIVE_LOW_OPTION| XSPIPS_FORCE_SSELECT_OPTION);\n\tXSpiPs_SetClkPrescaler(&amp;SpiInstance, XSPIPS_CLK_PRESCALE_64);\n}\n\n\nvoid delay(unsigned char i){\n\tvolatile int Delay;\n\tvolatile int k;\n\tfor(k=0;k&lt;i;k++)\n\tfor (Delay = 0; Delay &lt; 10000; Delay++);\n}\n\nvoid LCD_WR_DATA8(u8 dat){\n\tXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_CD, 1);\n\tXSpiPs_PolledTransfer(&amp;SpiInstance, &amp;dat, NULL, 1);\n}\n\nvoid LCD_WR_REG(u8 dat){\n\tXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_CD, 0);\n\tXSpiPs_PolledTransfer(&amp;SpiInstance, &amp;dat, NULL, 1);\n}\n\nvoid Lcd_Init(void){\n  XGpioPs_WritePin(&amp;Gpio, EMIO_LCD_RES, 0);\n  delay(10);\n  XGpioPs_WritePin(&amp;Gpio, EMIO_LCD_RES, 1);\n  delay(10);\n  LCD_WR_REG(0x36);\n  LCD_WR_DATA8(0x00);\n  LCD_WR_REG(0x3A);\n  LCD_WR_DATA8(0x05);\n  LCD_WR_REG(0xB2);\n  LCD_WR_DATA8(0x0C);\n  LCD_WR_DATA8(0x0C);\n  LCD_WR_DATA8(0x00);\n  LCD_WR_DATA8(0x33);\n  LCD_WR_DATA8(0x33);\n  LCD_WR_REG(0xB7);\n  LCD_WR_DATA8(0x35);\n  LCD_WR_REG(0xBB);\n  LCD_WR_DATA8(0x19);\n  LCD_WR_REG(0xC0);\n  LCD_WR_DATA8(0x2C);\n  LCD_WR_REG(0xC2);\n  LCD_WR_DATA8(0x01);\n  LCD_WR_REG(0xC3);\n  LCD_WR_DATA8(0x12);\n  LCD_WR_REG(0xC4);\n  LCD_WR_DATA8(0x20);\n  LCD_WR_REG(0xC6);\n  LCD_WR_DATA8(0x0F);\n  LCD_WR_REG(0xD0);\n  LCD_WR_DATA8(0xA4);\n  LCD_WR_DATA8(0xA1);\n  LCD_WR_REG(0xE0);\n  LCD_WR_DATA8(0xD0);\n  LCD_WR_DATA8(0x04);\n  LCD_WR_DATA8(0x0D);\n  LCD_WR_DATA8(0x11);\n  LCD_WR_DATA8(0x13);\n  LCD_WR_DATA8(0x2B);\n  LCD_WR_DATA8(0x3F);\n  LCD_WR_DATA8(0x54);\n  LCD_WR_DATA8(0x4C);\n  LCD_WR_DATA8(0x18);\n  LCD_WR_DATA8(0x0D);\n  LCD_WR_DATA8(0x0B);\n  LCD_WR_DATA8(0x1F);\n  LCD_WR_DATA8(0x23);\n  LCD_WR_REG(0xE1);\n  LCD_WR_DATA8(0xD0);\n  LCD_WR_DATA8(0x04);\n  LCD_WR_DATA8(0x0C);\n  LCD_WR_DATA8(0x11);\n  LCD_WR_DATA8(0x13);\n  LCD_WR_DATA8(0x2C);\n  LCD_WR_DATA8(0x3F);\n  LCD_WR_DATA8(0x44);\n  LCD_WR_DATA8(0x51);\n  LCD_WR_DATA8(0x2F);\n  LCD_WR_DATA8(0x1F);\n  LCD_WR_DATA8(0x1F);\n  LCD_WR_DATA8(0x20);\n  LCD_WR_DATA8(0x23);\n  LCD_WR_REG(0x21);\n  LCD_WR_REG(0x11);\n  LCD_WR_REG(0x29);\n  XGpioPs_WritePin(&amp;Gpio, EMIO_LCD_BL, 1);\n  }\n\n void LCD_WR_DATA(u16 dat)\n{\n\tu8 spi_dat[2];\n\tXGpioPs_WritePin(&amp;Gpio, EMIO_LCD_CD, 1);\n    spi_dat[0]=dat&gt;&gt;8;\n    spi_dat[1]=dat;\n    XSpiPs_PolledTransfer(&amp;SpiInstance, spi_dat, NULL, 2);\n}\n\nvoid Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)\n{\n   LCD_WR_REG(0x2a);\n   LCD_WR_DATA8(x1&gt;&gt;8);\n   LCD_WR_DATA8(x1);\n   LCD_WR_DATA8(x2&gt;&gt;8);\n   LCD_WR_DATA8(x2);\n   LCD_WR_REG(0x2b);\n   LCD_WR_DATA8(y1&gt;&gt;8);\n   LCD_WR_DATA8(y1);\n   LCD_WR_DATA8(y2&gt;&gt;8);\n   LCD_WR_DATA8(y2);\n   LCD_WR_REG(0x2C);\n}\n\n\n\nvoid LCD_Test()\n{\n    unsigned int i,j;\n    Address_set(0,0,240-1,240-1);\n\n    for(i=0;i&lt;240;i++){\n\n    \tif(i&gt;=0&amp;&amp;i&lt;60)\n    \t\tfor (j=0;j&lt;240;j++)LCD_WR_DATA(WHITE);\n\n    \telse if(i&gt;=60&amp;&amp;i&lt;120)\n    \t\tfor (j=0;j&lt;240;j++)LCD_WR_DATA(RED);\n\n    \telse if(i&gt;=120&amp;&amp;i&lt;180)\n    \t\tfor (j=0;j&lt;240;j++)LCD_WR_DATA(GREEN);\n\n    \telse if(i&gt;=180&amp;&amp;i&lt;240)\n    \t\tfor (j=0;j&lt;240;j++)LCD_WR_DATA(BLUE);\n    }\n}\n\n\nint main(void)\n{\n\tLcd_Gpio_Init();\n\tLcd_Spi_Init();\n\n\tLcd_Init();\n\tLCD_Test();\n\n\twhile(1);\n\n\treturn XST_SUCCESS;\n}\n\n<\/pre>\n\n\n\n<p>8\uff09\u7528\u4e4b\u524d\u751f\u6210\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u5bf9FPGA\u8fdb\u884c\u7f16\u7a0b\uff0c<code>Xilinx Tools<\/code>&nbsp;-&gt;&nbsp;<code>Program FPGA<\/code>&nbsp;\u7136\u540e\u70b9\u51fb \u201cProgram\u201d <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"307\" height=\"252\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-57.png\" alt=\"\" class=\"wp-image-293\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-57.png 307w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-57-300x246.png 300w\" sizes=\"auto, (max-width: 307px) 100vw, 307px\" \/><\/figure>\n\n\n\n<p>9\uff09\u5f53FPGA\u7f16\u7a0b\u6210\u529f\u540e\uff0c\u6211\u4eec\u9700\u8981\u521d\u59cb\u5316zynq\u4e2d\u7684\u5904\u7406\u5668\uff0c\u53f3\u952e\u70b9\u51fb\u521a\u624d\u521b\u5efa\u7684\u7a7a\u5de5\u7a0b\uff0c\u9009\u62e9<code>Run As<\/code>&nbsp;-&gt;&nbsp;<code>Launch on Hardware (System Debugger)<\/code>&nbsp;\u6216\u8005 Launch on Hardware (GDB).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"501\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-79.png\" alt=\"\" class=\"wp-image-347\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-79.png 703w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-79-300x214.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>\u7ecf\u8fc7\u4e0a\u8ff0\u64cd\u4f5c\uff0c\u5c4f\u5e55\u5c31\u88ab\u6210\u529f\u70b9\u4eae\u4e86\uff0c \u6b63\u5e38\u663e\u793a 4\u8272\u5f69\u6761\u7eb9\uff0c\u5982\u4e0b\u56fe\u6240\u793a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"415\" height=\"552\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-80.png\" alt=\"\" class=\"wp-image-348\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-80.png 415w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/image-80-226x300.png 226w\" sizes=\"auto, (max-width: 415px) 100vw, 415px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801\u89e3\u91ca<\/h2>\n\n\n\n<p>\u4ee5\u4e0a\u662f\u5b8c\u6574\u7684\u5de5\u7a0b\u56fe\u6587\u521b\u5efa\u8fc7\u7a0b\uff0c \u9664\u4e86\u4e0a\u9762\u63d0\u5230\u7684GPIO\u548c SPI\u90e8\u5206\u7684\u4ee3\u7801\u5916\uff0c\u4e0b\u9762\u7b80\u5355\u4ecb\u7ecd\u4e0b \u5de5\u7a0b\u4e2d\u7684\u5176\u4f59\u7684\u4e00\u4e9b\u51fd\u6570\u4ee3\u7801<\/p>\n\n\n\n<p>1\uff09\u5173\u4e8e\u989c\u8272<\/p>\n\n\n\n<p>\u5c4f\u5e55\u672c\u8eab\u662f16\u8272 \u4e5f\u5c31\u662fRGB565\u7684\u989c\u8272\u9a71\u52a8\u65b9\u5f0f \uff0c\u6240\u4ee5\u8fd9\u91cc\u53ef\u4ee5\u7528 16\u5b57\u8282\u6765\u5b9a\u4e49\u4e0d\u540c\u7684\u989c\u8272\uff0c\u5982\u7a0b\u5e8f\u4e2d\u7684\u7ea2\u7eff\u84dd\u767d\uff0c\u4ee5\u53ca\u4e0b\u9762\u6807\u6ce8\u7684\u5176\u4ed6\u989c\u8272\uff0c \u5f53\u7136\u4e5f\u53ef\u4ee5\u6839\u636eRGB\u7684\u989c\u8272\u7ec4\u5408\u6765\u5408\u6210\u81ea\u5df1\u9700\u8981\u7684\u989c\u8272<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#define WHITE         \t 0xFFFF\n#define BLACK         \t 0x0000\n#define BLUE         \t 0x001F\n#define BRED             0XF81F\n#define GRED \t\t 0XFFE0\n#define GBLUE\t\t 0X07FF\n#define RED           \t 0xF800\n#define MAGENTA       \t 0xF81F\n#define GREEN         \t 0x07E0\n#define CYAN          \t 0x7FFF\n#define YELLOW        \t 0xFFE0\n#define BROWN \t         0XBC40\n#define BRRED \t\t 0XFC07\n#define GRAY  \t\t 0X8430<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p id=\"block-406e7490-888d-46bd-9c00-0bb3cd759e6e\">2)\u5173\u4e8e\u5f69\u8272\u6761\u7eb9 \uff0c\u5982\u4e0b\u4ee3\u7801\uff0c0-60\u884c\u663e\u793a\u767d\u8272\uff0c60-120\u663e\u793a\u7ea2\u8272\uff0c120-180\u663e\u793a\u7eff\u8272\uff0c180-240\u663e\u793a\u84dd\u8272<\/p>\n\n\n\n<p>Address_set(0,0,240-1,240-1); \u76f8\u5f53\u4e8e\u662f\u5b9a\u4e49\u4e00\u5757\u77e9\u5f62\u533a\u57df\uff0c0\uff0c0\uff0c240\uff0c240\u5206\u522b\u662f\u8fd9\u4e2a\u77e9\u5f62\u7684\u56db\u4e2a\u5750\u6807\u70b9\uff08\u8fd9\u91cc\u6db5\u76d6\u4e86\u6574\u4e2a\u5c4f\u5e55\u7684\u7a7a\u95f4\uff0c\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u90e8\u5206\u533a\u57df\uff0c\u8be6\u7ec6\u770b\u5c4f\u5e55\u624b\u518c\uff09<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void LCD_Test()\n{\n    unsigned int i,j;\n    Address_set(0,0,240-1,240-1);\n\n    for(i=0;i&lt;240;i++){\n\n    \tif(i&gt;=0&amp;&amp;i&lt;60)\n    \t\tfor (j=0;j&lt;240;j++)LCD_WR_DATA(WHITE);\n\n    \telse if(i&gt;=60&amp;&amp;i&lt;120)\n    \t\tfor (j=0;j&lt;240;j++)LCD_WR_DATA(RED);\n\n    \telse if(i&gt;=120&amp;&amp;i&lt;180)\n    \t\tfor (j=0;j&lt;240;j++)LCD_WR_DATA(GREEN);\n\n    \telse if(i&gt;=180&amp;&amp;i&lt;240)\n    \t\tfor (j=0;j&lt;240;j++)LCD_WR_DATA(BLUE);\n    }\n}<\/pre>\n\n\n\n<p>\u6700\u540e\u4ecb\u7ecdmain \u51fd\u6570\uff0c\u5176\u5b9e\u7279\u522b\u7b80\u5355\uff0c\u5305\u62ecGPIO\u7684\u521d\u59cb\u5316\uff0cSPI\u7684\u521d\u59cb\u5316\uff0c \u4ee5\u53ca\u5c4f\u5e55\u7684\u521d\u59cb\u5316\uff08\u5c4f\u5e55\u5185\u90e8\u5bc4\u5b58\u5668\u7684\u914d\u7f6e \u914d\u7f6e\u4fe1\u606f\u7531\u5382\u5bb6\u76f4\u63a5\u63d0\u4f9b\uff09\uff0c\u4ee5\u53ca\u5c4f\u5e55\u6d4b\u8bd5\u51fd\u6570\u7684\u8c03\u7528<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int main(void)\n{\n\tLcd_Gpio_Init();\n\tLcd_Spi_Init();\n\n\tLcd_Init();\n\tLCD_Test();\n\n\twhile(1);\n\n\treturn XST_SUCCESS;\n}<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u4ee5\u4e0b\u9644\u4ef6\u4e3a \u672c\u9875\u5185\u5bb9\u7684\u5b8c\u6574\u5de5\u7a0b\uff08<strong>\u4ee3\u7801\u4e2d\u5df2\u7ecf\u89e3\u51b3\u4e4b\u524d\u7684\u517c\u5bb9\u6027\u95ee\u9898<\/strong>\uff09<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-f2d5af37-a140-47cf-bfcc-944add764990\" href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/07_PS_LCD_TEST_SPI-1.zip\">07_PS_LCD_TEST_SPI<\/a><a href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2021\/08\/07_PS_LCD_TEST_SPI-1.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-f2d5af37-a140-47cf-bfcc-944add764990\">\u4e0b\u8f7d<\/a><\/div>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">PS \u539f\u5148\u6d4b\u8bd5\u8fc7\u7a0b\u4e2d\uff0c ZYNQ \u7684SPI\u603b\u611f\u89c9\u548cLCD\u5c4f\u4e0d\u592a\u517c\u5bb9\uff0c\u6700\u540e\u7ecf\u8fc7\u522b\u4eba\u7684\u63d0\u9192\uff0c\u53d1\u73b0\u662fSPI\u521d\u59cb\u5316\u7684\u65f6\u5019 \u6709\u70b9\u95ee\u9898\uff0c \u589e\u52a0\u4e0b\u9762\u8fd9\u884c\u4ee3\u7801\u5c31\u53ef\u4ee5\u4e86<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"622\" height=\"192\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/05\/image-11.png\" alt=\"\" class=\"wp-image-743\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/05\/image-11.png 622w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/05\/image-11-300x93.png 300w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u63a5\u677f\u4e0a\u81ea\u5e26\u4e86\u4e00\u5757LCD \u5c4f\u5e55\uff0c\u53d7IO\u8d44\u6e90\u9650\u5236\uff0c\u5c4f\u5e55\u7684\u63a5\u53e3\u4f7f\u7528\u4e86\u5360\u7528\u7ebf\u5e8f\u6bd4\u8f83\u5c11\u7684SPI\u63a5\u53e3\uff0c\u672c\u6587\u5c06\u901a\u8fc7ZYNQ\u7684PS\u8d44\u6e90\u53bb\u70b9\u4eae\u8fd9\u4e2a\u6db2\u6676\u5c4f\u5e55<\/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-309","post","type-post","status-publish","format-standard","hentry","category-ebaz4205"],"views":1196,"_links":{"self":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/309","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=309"}],"version-history":[{"count":29,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/309\/revisions"}],"predecessor-version":[{"id":6212,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/309\/revisions\/6212"}],"wp:attachment":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/media?parent=309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/categories?post=309"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/tags?post=309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}