[posted] Commodore C64 Emulation on a Teensy 3.6 Microcontroller

OK, some info for you...

Compiled with the JiffyDOS ROM (and turned off the ROM patches). Now, when I boot up if I type @$ <RETURN> to get a directory the drive comes on, steps to track 18, and then the bus hangs. When I turn off the drive and turn it back on, the C64 cursor comes back but the keyboard never recognizes the RETURN and some other keys anymore! I have to reboot (CTRL-ALT-DEL) the Teensy64.

Now... what is interesting is that if I type @I <RETURN> to initialize the drive, and then type @$<RETURN>, I get the directory perfectly! If I immediately type @$<RETURN> again, the bus hangs and I have to reboot. But.. if I always enter @I<RETURN> before I attempt to get the directory, then I can get the directory every single time! It's like after a directory read the CIA DDR is not correct, or CLK/DAT/ATN is not set correctly.

::edit::

Ok, the above works fine (@I followed by @$), but ONLY if I don't let the 1541 motor stop running between the @I and @$ commands! If the motor stops between commands, then the bus hangs when trying to get the directory. This is 100% repeatable.

By the way, this is using JiffyDOS only the C64 side. I have not tried testing with a drive that also has JiffyDOS.
 
Last edited:
Thanks ! I try to find the reason. And I will order a floppydrive this weekend. I hope it will work better than the last one..
But the bug must be something simple. Maybe I can find it without having a 15x1
 
Ordered ;-) I hope I have it end of next week. With a bit luck, I'll get a second drive and a original C64, too.
 
That's great. I would have offered to send you a 1541, but the shipping cost would have been ridiculous from the U.S. to Germany, and it would have never made it there without the drive alignment being knocked out wack! :)
 
Hi Frank,

Was wondering with the VGA board, do we need to add the Diode you showed on the picture in the post: https://forum.pjrc.com/threads/46886-Sn74cbtd3861?p=156092&viewfull=1#post156092

If so did you need to cut the trace going to the pin? Which diode did you use? I have a package of through hole diodes (a pack from Amazon with 10 different ones)... So hopefully one of them will work.

P.S - Other than that I think I have the board assembled. Won't be able to test for a few days... Did not find any VGA cables... I most of tossed them awhile ago :( ordered one from Amazon.
 
Hi Frank,

Was wondering with the VGA board, do we need to add the Diode you showed on the picture in the post: https://forum.pjrc.com/threads/46886-Sn74cbtd3861?p=156092&viewfull=1#post156092

If so did you need to cut the trace going to the pin? Which diode did you use? I have a package of through hole diodes (a pack from Amazon with 10 different ones)... So hopefully one of them will work.

P.S - Other than that I think I have the board assembled. Won't be able to test for a few days... Did not find any VGA cables... I most of tossed them awhile ago :( ordered one from Amazon.

Hi, the diode is not a good solution.. if you really want to mess with it, any (500mA minimum) will work. Cut the VCC trace between the ic- pin1 pad and the via nearby, and insert the diode between 5v+ and pin1. I have no idea which part-# the diode on the picture is, I bought 100 of them years ago and there is no marking. It's just to lower the voltage a little bit. The IC is for levelshifting only. You don't need it, if you don't have a diskdrive and nothing attached to the IEC bus. But, if you soldered it, I'd add the diode, yes.. and please measure the voltage on the outputs.

I made new boards.. will take a short time.
 
Last edited:
How can I get a board? I've managed to compile no problem, would like to make something more permanent and play around making launcher / menu for prg's.
 
@itec: PM "Frank B" - which board you are interested in and your destination country - the original ILI9341's are on hand - newer boards are evolving for using VGA.
 
Hi. The VGA boards are not for sale. The are for tests only!
I made new but they are still in production/test.
 
JimDrew - glad you got up and running. I can confirm my test builds just uploaded to my ILI9341 Teensy64 from that new machine and work with one of my newly pinned T_3.6's.
 
Hi, the diode is not a good solution.. if you really want to mess with it, any (500mA minimum) will work. Cut the VCC trace between the ic- pin1 pad and the via nearby, and insert the diode between 5v+ and pin1. I have no idea which part-# the diode on the picture is, I bought 100 of them years ago and there is no marking. It's just to lower the voltage a little bit. The IC is for levelshifting only. You don't need it, if you don't have a diskdrive and nothing attached to the IEC bus. But, if you soldered it, I'd add the diode, yes.. and please measure the voltage on the outputs.

I made new boards.. will take a short time.

Hi Frank, I put on the Diode. My VGA cable arrived so I plugged it into an old unused monitor. Took a few minutes figuring out how to compile for VGA mode.
I added -DVGA=1
in the defs.h file

The compiler was having issues finding uVGA.h, which I had downloaded into my <sketch folder>/libraries directory and restarted the Arduino IDE, plus cleared out all stuff out of my %temp% folder associated with Arduino.
So added the #include to the top level sketch and it built and installed.

The vga screen come up :D BUT the USB Mouse is not working. I tried running the USBHOst test program (mouse) and it is now showing anything either...

Was wondering if I need to do something with the Solder jumpers on the bottom SJ1/SJ2?
IMG_0153.jpg

IMG_0152.jpg

Will take out volt meter and see what is happening.
 
Kurt: Thanks for the pics and details. I was on the verge of building mine up and your details will save me some work :)

Looks like I need to reset my system to use the DEFS.h file - I took a shortcut to build for Jim the other day hacking the TD sources - but that won't give the -DVGA=1 switch. I'll see if that works with the beta 1.9.0 build engine that does a full compile in 2/3'rds the time.

> I noted that closing the IDE deletes the %temp% folder in use - so it should start fresh when re-opened.

AFAIK from schematic those two jumpers cut USB connect over to use PS/2 style connection. I'll forward that PDF.
 
Hm, seems that a mail got lost.. I was sure that I sent you all Info, Kurt. You have to close the jumpers accordingly. (Remove the Teensy before soldering, and use a multimeter to check the connections between teensy-USB and the USB socket)
Yes, when changing the options in defs.h, it's needed to restart Arduino, because the builder does not recongnize the changes.
That's needed too, if you edit settings.h - sometimes the builder-caching bug will do (not -) funny things..
 
Thanks Frank - I looked at the schematic you sent and wrongly assumed there were default lines connecting the USB by default even though I couldn't see that in the drawing.
 
No, no default - To be honest, I didn't find any way to close a Jumper in EAGLE. I wonder if there is a "legal" way without tricks..
 
Ok..
Got the drive this evening (wow - that was fast) , and I have it working - need to backport the workaround to the old version on github and do some tests with sd2iec AND the floppydrive.
@Jim, don't know if that works at the moment - it's too late here - but if you want to try it:
Comment out line 1950: https://github.com/FrankBoesing/Teensy64/blob/master/Teensy64/vic.cpp#L1950
I have a similar line in the new VIC-Code, and that helped.
I really want to get the new VIC done.. If I only had some more free time...

Edit: or, better, try: cpu.vic.badline = 0;

Edit: Or, best, wait a bit.. i'll update github tomorrow.. maybe, more changes are needed for that version.
 
Last edited:
Thanks guys,

After I posted, I unplugged Teensy and then used multimeter to verify that the USB pins of the Teensy go to the pin of the jumpers with the center pads go to the USB connector. So pulled soldering iron back out and closed the
jumpers.

Now USB is working :D

Sorry I don't know Eagle well enough.. I use Diptrace and have the same issues with how to close the jumper.

I know that the Sparkfun Eagle libraries has components for jumpers, some with the jumpers closed and some without... However when ever I use them (I import them into a Diptrace library). The verification code complains about shorts...
Might be able to ignore them. Or maybe there is some trick like put the etch between them on some different layer and then have the gerber some how merge them...

I was able to download the program. to the board. I noticed during the build that it wanted me to set USB type to RAWHID so I did so... Was able to run a few of the programs. Sometimes when I boot, the screen image breaks up. Other times works pretty well.

When you build for VGA Do you still want the program to run at 240 and the like?
 
Hi Kurt, yes, 240MHz are needed. 120MHz FBUS, hm, maybe not :)
RAWHID, or even better NOUSB causes less glitches and an very good picture - with other USB-Modes, you may get heavy pixel-flicker.
 
I also have several USB to serial adapters I can use to talk to Serial2 ;)

The best one is a TEENSY! ... but yes , I heard you have a FEW :) . . . yeah that was my idea when I made the reverse table to find the free pins - drop interference from PC USB and still have a reliable SerMon.

Uploaded the XLS file for used pins - the ILI9341 : ReversePinMap.xlsx
 
Last edited:
Ok..
Got the drive this evening (wow - that was fast) , and I have it working - need to backport the workaround to the old version on github and do some tests with sd2iec AND the floppydrive.
@Jim, don't know if that works at the moment - it's too late here - but if you want to try it:
Comment out line 1950: https://github.com/FrankBoesing/Teensy64/blob/master/Teensy64/vic.cpp#L1950
I have a similar line in the new VIC-Code, and that helped.
I really want to get the new VIC done.. If I only had some more free time...

Edit: or, better, try: cpu.vic.badline = 0;

Edit: Or, best, wait a bit.. i'll update github tomorrow.. maybe, more changes are needed for that version.

I will try commenting out line 1950. So this is a badlines issue stealing CPU cycles? I am glad you found your 1541 drive didn't work too!

EDIT: OK, that did not change anything. :( In fact, it might actually be worse because I can't do the @I and @$ back to back and always get the directory. Also, when the bus hangs if I turn off the disk drive, the RETURN key and other keys no longer work. I have to reboot the Teensy. This tells me that the CIA is in some odd ball state where the keyboard doesn't work. However, I think the CIA that is connected to the keyboard is not the same one connected to the disk drive. Is it possible that you have the control registers swapped or are using the wrong one in the IEC stuff?
 
Last edited:
I will try commenting out line 1950. So this is a badlines issue stealing CPU cycles? I am glad you found your 1541 drive didn't work too!

EDIT: OK, that did not change anything. :( However, I think the CIA that is connected to the keyboard is not the same one connected to the disk drive. Is it possible that you have the control registers swapped or are using the wrong one in the IEC stuff?

No.
I found the real reason for the not working drives: They are much slower than SD2IEC, and there is a long pause on the IEC Bus - the emu thought "ah, ok, IEC ready" and switched to the normal mode.
The badline-hack from yesterday was enough to make it a little bit faster, with my new version.
I hope, it works now, - at least a bit better - would you please give it a try ? I've tested with a 1541 and some short programs from disk and played a little with sd2iec.
I did NOT test with jiffy- will do that later...

Edit: Oops... I should mention, that I updated Github and added a new HEX-File..
 
Last edited:
Back
Top