{"id":132,"date":"2012-07-08T23:30:18","date_gmt":"2012-07-08T23:30:18","guid":{"rendered":"http:\/\/retroramblings.net\/?p=132"},"modified":"2012-07-08T23:33:43","modified_gmt":"2012-07-08T23:33:43","slug":"experimenting-with-tg68-8","status":"publish","type":"post","link":"http:\/\/retroramblings.net\/?p=132","title":{"rendered":"Experimenting with TG68"},"content":{"rendered":"<p><strong>Part 8 &#8211; Timers and C code<\/strong><\/p>\n<p>Having successfully uploaded an S-record program over RS232 last time, I&#8217;ve since followed the helpful instructions in<a href=\"https:\/\/github.com\/cnvogelg\/minimig_tc64\/blob\/gcc\/doc\/toolchain.txt\"> Christian Vogelgsang&#8217;s Chameleon Minimig repo<\/a> for setting up a cross-compilation toolchain.\u00a0 I&#8217;m now able to build C software for this project, which in the absence of a more imaginative name, I&#8217;m coming to think of as &#8220;MiniSOC&#8221;.<\/p>\n<p>(In fact, I haven&#8217;t used newlib &#8211; and nor did Christian in the finish &#8211; instead we&#8217;ve drawn from <a href=\"http:\/\/www.kernel.org\/pub\/linux\/libs\/klibc\/2.0\/\">klibc<\/a>, just cherry-picking the routines needed for the task at hand.\u00a0 There are also a couple of other dependencies for building GCC &#8211; gmp, mpfr and mpc, which are a stack of libraries for handling multi-precision arithmetic.)<\/p>\n<p>Since I&#8217;m not familiar with the syntax used by GCC&#8217;s assembler (which is very unlike the &#8220;normal&#8221; Motorola syntax) I also used <a href=\"VASM\">VASM<\/a> to build assembly components to Elf format, then the cross-compiled objdump to create S-records from the final project.<\/p>\n<p>I also used srec_cat, as before, to create .mif files from the lowest-level startup file, which ends up in an M4K.<\/p>\n<p>The biggest change hardware-wise this time round is the addition of some timers.\u00a0 There are now eight in total, two of which directly divide the system clock, and the other six divide the output of the first timer.\u00a0 Three of those run in continuous mode, and three run as one-shot timers.<\/p>\n<p>An event on any of those six timers will trigger an interrupt, and the one timer I haven&#8217;t yet mentioned will eventually be used to provide an SPI clock when I implement SD card access.<\/p>\n<p>The firmware file CFirmware\/out.srec contains basically the same graphics demo as previous builds, implemented in assembler, but with the housekeeping and keyboard\/mouse drivers in C.\u00a0 One of the one-shot timers is used to provide a mouse time-out, so the project will still run even if there&#8217;s no mouse connected.<\/p>\n<p>Thanks to code borrowed from klibc, the FrameBuffer&#8217;s address is no longer hardcoded, and instead is malloc()ed.\u00a0 Since there&#8217;s no operating system to provide memory blocks to the malloc arena, I&#8217;ve added a routine to add a hardcoded block of memory for use by malloc().\u00a0 The actual bounds of that block are specified by the GCC linker script.\u00a0 This allows me to hardcode the upper bound to match the hardware, but have the lower bound automatically set immediately above the region occupied by the firmware itself.<\/p>\n<p><a href=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/07\/MiniSOC_Part8.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-136\" title=\"MiniSOC_Part8\" src=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/07\/MiniSOC_Part8.jpg\" alt=\"\" width=\"640\" height=\"426\" srcset=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/07\/MiniSOC_Part8.jpg 640w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/07\/MiniSOC_Part8-300x199.jpg 300w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/07\/MiniSOC_Part8-450x300.jpg 450w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>This version has a keyboard driver, too &#8211; incomplete but functional enough that what you type ends up on screen.\u00a0 Mouse buttons are also detected, and will cause the colours to cycle more rapidly.<\/p>\n<p>Full source and binaries <a href=\"http:\/\/retroramblings.net\/downloads\/DE1_TG68Test_Part8_Timers.zip\">can be found here.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Part 8 &#8211; Timers and C code Having successfully uploaded an S-record program over RS232 last time, I&#8217;ve since followed the helpful instructions in Christian Vogelgsang&#8217;s Chameleon Minimig repo for setting up a cross-compilation toolchain.\u00a0 I&#8217;m now able to build &hellip; <a href=\"http:\/\/retroramblings.net\/?p=132\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-132","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=132"}],"version-history":[{"count":5,"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/132\/revisions"}],"predecessor-version":[{"id":141,"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/132\/revisions\/141"}],"wp:attachment":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}