{"id":22,"date":"2007-04-07T17:15:21","date_gmt":"2007-04-07T15:15:21","guid":{"rendered":"http:\/\/lallafa.de\/blog\/??p=22"},"modified":"2007-04-09T11:43:32","modified_gmt":"2007-04-09T09:43:32","slug":"added-a-mmc2iec-to-my-dtv64","status":"publish","type":"post","link":"https:\/\/lallafa.de\/blog\/2007\/04\/added-a-mmc2iec-to-my-dtv64\/","title":{"rendered":"Added a MMC2IEC to my DTV64"},"content":{"rendered":"<p>Easter time is project time \ud83d\ude09 I spent the free days with working on some of my C64 hardware projects&#8230; This time I added a SD-Card based virtual 1541 Floppy emulator to my DTV mod. I integrated <a href=\"http:\/\/pontoppidan.info\/lars\/index.php?proj=mmc2iec\">Lars&#8217;s MMC2IEC Project<\/a> that implements this HW floppy with an Atmel ATmega32 microcontroller and just a few more parts (available for a few bucks).\n<\/p>\n<p>\nHere is how I built it and how to use the Mac as a development system for the AVR controller&#8230;<br \/>\n<!--more--><\/p>\n<h3>Hardware<\/h3>\n<p>\nMy DTV mod uses a small plastic box as a housing and I wanted to integrate the MM2IEC board inside this case. I came up with the idea to set up the circuit board on the top (and free) side of the case. I use a prototype circuit board and a DIP version of the AVR to build the board:\n<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.lallafa.de\/blog\/wp-content\/uploads\/2007\/04\/dtv-mmc2iec-board.jpg?w=584&#038;ssl=1\"  \/><\/p>\n<p>\nThe SD\/MMC-Card connector is a surface mounted version from my local electronics store that I simply glued to the top case. On the left are the two status LEDs, also glued to the top case. Both the SD Card and the LEDs are wired with a 10-pin circuit board connector to the MMC2IEC board.<\/p>\n<p>On the top left side of the board is a 10-pin connector wired up as an ISP port, used to program the flash ROM of the AVR controller. The connector fits directly to the USB ISP programmer called <a href=\"http:\/\/www.myavr.de\/shop\/artikel.php?artID=42\">mySmartUSB<\/a> I use to program the chip directly via USB from my Mac (see below).<\/p>\n<p>On the bottom right side of the AVR is a 10-pin connector that is used as connection to the DTV on the other side of the case. It includes 2 pins for 3.3V power supply and ground, a reset pin to reset the IEC emulation and the 3 control lines for the IEC bus.<\/p>\n<p>Here you can see the full DTV mod with both case sides side-by-side and alread connected:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.lallafa.de\/blog\/wp-content\/uploads\/2007\/04\/dtv-both-boards.jpg?w=584&#038;ssl=1\" \/>\n<\/p>\n<p>\nOn the rear side of the DTV box I added two new components: a IEC reset button and a power switch for the MMC2IEC. Both components are wired on the bottom case side and connected to my I\/O board already found there. The connector from the MMC2IEC board uses the reset trigger from there. The 3.3V is taken from the DTV main board and passed to a connector array on the I\/O board (on the left side) where it is switched by the back power switch. The switched voltage is then fed to the MMC2IEC by the connector. The IEC power switch allows me to disable the MMC2IEC virtual floppy and to use a real 1541 connected to the IEC connector.\n<\/p>\n<p>\nHere is a snapshot of the new front side with new the SD slot and the two status LEDs of MMC2IEC:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.lallafa.de\/blog\/wp-content\/uploads\/2007\/04\/dtv-front.jpg?w=584&#038;ssl=1\" \/><\/p>\n<p>\nThis is the new flipside with the IEC reset and MMC2IEC power button:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.lallafa.de\/blog\/wp-content\/uploads\/2007\/04\/dtv-back.jpg?w=584&#038;ssl=1\" \/><\/p>\n<h3>Software<\/h3>\n<p>\nThe MMC2IEC requires a firmware in the flash ROM of the ATmega32 to run. Here is a summary of the steps required to cross-compile the c-source for the board and how to transfer it.\n<\/p>\n<p>The source of the MMC2IEC is available on <a href=\"http:\/\/pontoppidan.info\/lars\/index.php?proj=mmc2iec&#038;page=4\">Lar&#8217;s MMC2IEC Download Page<\/a>. Download and unpack it. The included Makefile requires a gcc cross compiler called <em>avr-gcc<\/em>.<\/p>\n<p>Till Harbaum has written a nice tutorial <a href=\"http:\/\/www.harbaum.org\/till\/macavr\/index.html\">MacAVR  development on Mac OS X<\/a> on how to set up a AVR gcc environment on your Mac. With his tutorial all the required tools are built and installed in a few minutes.<\/p>\n<p>With the AVR tools now in your PATH, a simple <em>make<\/em> in your shell will build the final firmware hex file. I had to comment out the <code>DEBUG=dwarf-2<\/code> in the makefile because my compiler did not support this format.<\/p>\n<p>\nTo burn the firmware into your ATmega you need the following set up: Disconnect the MMC2IEC from the DTV board and also disconnect the SD-Connector with the LEDs. Now the MMC2IEC board is powerless and has no connection to peripherals. Hook up your ISP-USB adapter (mySmartUSB) in the ISP port and configure the adapter to supply power for the ATmega (see the adapter manual). Now connect the ISP-USB to your Mac via USB and you are ready to burn the firmware&#8230;<\/p>\n<p>For ISP programming I use the great <a href=\"http:\/\/www.nongnu.org\/avrdude\/\">avrdude<\/a>. Just compile and install it. The makefile already has a <code>make program<\/code> rule. You only need to adjust some parameters (your mileage may vary):\n<\/p>\n<p>\n<code<br \/>\nAVRDUDE_PROGRAMMER = avr910<br \/>\nAVRDUDE_PORT = \/dev\/cu.SLAB_USBtoUART<br \/>\n<\/code>\n<\/p>\n<p>\n<em>make program<\/em> runs avrdude to program the flash:\n<\/p>\n<p>\n<code>avrdude -p atmega32 -P \/dev\/cu.SLAB_USBtoUART -c avr910 -U flash:w:mmc2iec.hex<\/code>\n<\/p>\n<p>I use the following <a href=\"http:\/\/www.silabs.com\/tgwWebApp\/public\/web_content\/products\/Microcontrollers\/USB\/en\/mcu_vcp.htm\">UART Driver<\/a> to access the mySmartUSB programmer on my Mac.<\/p>\n<p>\nIf you successfully flashed the ATmega you are almost ready to go&#8230; Almost, as you need to set the FUSE bits in your AVR correctly otherwise the whole thing won&#8217;t run! Setting these bits is a bit tricky, but AndyDTV showed it nicely on a <a href=\"http:\/\/www.forum64.de\/wbb2\/thread.php?threadid=14822&#038;threadview=0&#038;hilight=&#038;hilightuser=0&#038;page=3\">Forum 64 Post<\/a>:\n<\/p>\n<p><pre>\n[ ] OCDEN\n[ ] JTAGEN \/\/ disable JTag\n[x] SPIEN\n[ ] CKOPT\n[ ] EESAVE\n[x] BOOTSZ1\n[x] BOOTSZ0\n[ ] BOOTRST\n\n[ ] BODLEVEL\n[x] BODEN \/\/ enable Brown-out-detector\n[x] SUT1 [ ] SUT0\n[x] CKSEL3 [ ] CKSEL2 [x]CKSEL1 [x]CKSEL0 \/\/ 8 Mhz internal\n<\/pre>\n<\/p>\n<p>These values can be converted into an avrdude call for the first time initialization of the device:<\/p>\n<p>\n<code>avrdude -p atmega32 -P \/dev\/cu.SLAB_USBtoUART -c avr910 -U lfuse:w:0x94:m -U hfuse:w:0xd9:m -U flash:w:mmc2iec.hex<\/code>\n<\/p>\n<p>\nIf the FUSE bits are set up correctly then you are ready to go: Power on and cross your fingers \ud83d\ude00 If everything went well the two LEDs blink shortly and from now on the inserted SD-Card responds to device 8 in your DTV. Copy your favorite programs onto it and enjoy them on your DTV. (Have a look at the MMC2IEC manual for a description how to use D64 images&#8230;)\n<\/p>\n<p>\nNow I will enjoy my new virtual drive, check out some games and later on will have a look on the MMC2IEC source to see what can be hacked there \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Easter time is project time \ud83d\ude09 I spent the free days with working on some of my C64 hardware projects&#8230; This time I added a SD-Card based virtual 1541 Floppy emulator to my DTV mod. I integrated Lars&#8217;s MMC2IEC Project &hellip; <a href=\"https:\/\/lallafa.de\/blog\/2007\/04\/added-a-mmc2iec-to-my-dtv64\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2,6],"tags":[],"class_list":["post-22","post","type-post","status-publish","format-standard","hentry","category-commodore-64","category-mac-stuff"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/piBMF-m","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/posts\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":0,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"wp:attachment":[{"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}