{"id":864,"date":"2014-06-30T23:01:05","date_gmt":"2014-06-30T23:01:05","guid":{"rendered":"http:\/\/retroramblings.net\/?p=864"},"modified":"2026-08-14T12:56:44","modified_gmt":"2026-08-14T12:56:44","slug":"writing-to-a-tft-screen-with-zpuflex-2","status":"publish","type":"post","link":"https:\/\/retroramblings.net\/?p=864","title":{"rendered":"Writing to a TFT screen with ZPUFlex"},"content":{"rendered":"<p><strong>Part 2: DMA<\/strong><\/p>\n<p>In my last post I&#8217;d hooked up a TFT screen to an FPGA dev board and got some simple driver software running on the ZPUFlex CPU core.\u00a0 While it worked, having the CPU spoonfeed a frame of video data, byte-by-byte over an SPI link isn&#8217;t ideal, so I implemented a DMA process to handle the hard work.<\/p>\n<p><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/sS0RTKB8Ct0\" height=\"315\" width=\"420\" allowfullscreen=\"\" frameborder=\"0\"><\/iframe><br \/>\n<!--more-->Having sent the &#8220;write&#8221; commands to the display, the CPU now writes the framebuffer address, followed by the number of 16-bit words to be transferred to two new registers, which triggers the DMA process.<\/p>\n<p>When the DMA process has completed, an interrupt is triggered, in which the software triggers the next frame transfer.<\/p>\n<p>Without having made any special effort to optimise the SPI transfer, the project currently transfers 19 frames per second over a 50MHz SPI link.<\/p>\n<p>Test patterns are all very well, but I wanted the display to show something more interesting, so I added software to load an image file off the SD card, and shook out a couple of bugs in the CPU core and supporting libraries in the process, most notable in the byte-swap routine used when accessing partition tables from SD card.\u00a0 What I hadn&#8217;t realised is that GCC short-circuits certain shift instructions by using a loadb command.\u00a0 This fails when it&#8217;s being used to access part of a local variable because I haven&#8217;t implemented loadb from stack RAM.\u00a0 To fix this, I&#8217;ve simply made the ZPU drop back to emulation if loadb (or loadh) is attempted from stack RAM, while still allowing hardware versions of the instructions for external RAM.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Part 2: DMA In my last post I&#8217;d hooked up a TFT screen to an FPGA dev board and got some simple driver software running on the ZPUFlex CPU core.\u00a0 While it worked, having the CPU spoonfeed a frame of &hellip; <a href=\"https:\/\/retroramblings.net\/?p=864\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8],"tags":[],"class_list":["post-864","post","type-post","status-publish","format-standard","hentry","category-fpga","category-hardware"],"_links":{"self":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=864"}],"version-history":[{"count":5,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/864\/revisions"}],"predecessor-version":[{"id":2106,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/864\/revisions\/2106"}],"wp:attachment":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}