14 comments on “Running in circles

  1. Excellent!!!
    I’m also tinkering with old Motorola stuff at the moment but I used the SID, aka MOS6581, for my first project. It’s yet another SID player but this was done as an exercise prior to attacking the bigger “sister” Paula. My goal is to build a hw tracker player based on the Paula chip from the Amiga 500.
    No emulators around provide the same audio output so it needs to be done 😉

    I shall follow this build with excited eyes because I sincerely miss the “old” days.

  2. I was wondering if you could post your free run sketch for the arduino. I have an arduino and 6502 and would like to give this a try but my programming from scratch is limiting.

    • Here’s what I used for monitoring the free run and running the clock. It counts the number of times we loop through memory and tries to detect resets.

      /* Project 65
       * Bootstrap test
       const int clock_pin = 3;
       const int num_pins = 8;
       /* address bus pins hooked to high byte of address bus */
       const int address_bus_pins[] = {5,6,7,8,9,10,11,12};
       void setup ()
         pinMode (clock_pin, OUTPUT);
         for (int i = 0; i < num_pins; ++i)
           pinMode (address_bus_pins[i], INPUT);
         Serial.begin (115200);
       int address;
       int last_address = 0;
       int reset_count = 0;
       int roll_count = 0;
       void loop ()
         // cycle clock - slowly
         digitalWrite (clock_pin, LOW);
         delay (1);
         digitalWrite (clock_pin, HIGH);
         // read address bus
         address = 0;
         for (int i = 0; i < num_pins; ++i)
           address = address << 1;
           address += (digitalRead (address_bus_pins[num_pins-i-1]) == HIGH)?1:0;
         // write the address as it changes, so we have some indication
         // that things are happening.
         if (address != last_address)
           Serial.print (int2hex ((address >> 4)));
           Serial.println (int2hex (address & 0xf));
         if (address == 0xea)
           if (last_address == 0xea)
           else if (last_address == 0xe9)
             // we've completed a full loop through memory
             Serial.print ("roll count: ");
             Serial.println (roll_count++);
             // we've jumped directly to EAxx instead of
             // getting there by incrementing address register.
             Serial.print (reset_count++);
             Serial.println (": Reset detected!!!!");
         last_address = address;   
       char int2hex (int h)
         if (h >= 0 && h <= 9)
           return '0' + h;
         else if (h >= 10 && h <= 15)
           return 'a' + h-10;
           return '?';
  3. Wiring up the breadboard now. The caps are 47uf? Should I be using some 104 .1uf decoupling caps?
    I’ve been keeping a close eye on veronica over at blondihacks, I think I saw you post a few comments over there. Eventually I would like to do something like that with my 6502 but i think some experimental projects with the arduino will get me more familiar with how the 6502 works.
    Thanks for all the awesome info and insight!

    • The smoothing capacitor (the one on the left) is 100 uf. The cap in the reset circuit was 10 uf – but I had trouble with the reset circuit later on, and eventually removed the capacitor completely. I still need to come up with a better reset circuit.

      At this stage I didn’t have any decoupling caps, but I did add them later when I had a few more chips hooked up. I used .1uf for those, since that’s what most of the sources I’ve looked at suggest.

      Good luck!

  4. LOL
    I hit a snag with the code, it won’t compile.
    Stops at: Serial.print (“roll count: “);
    I’m using arduino 1.0.3 with an uno.
    Found a similiar sketch for reading to the serial monitor but doesn’t solve my problem.

    Here’s the error I get:
    freerun:48: error: stray ‘\’ in program
    freerun:48: error: stray ‘\’ in program
    freerun:56: error: stray ‘\’ in program
    freerun:56: error: stray ‘\’ in program
    freerun.ino: In function ‘void loop()’:
    freerun:37: error: expected primary-expression before ‘>’ token
    freerun:37: error: expected `;’ before ‘)’ token
    freerun:48: error: ‘u201croll’ was not declared in this scope
    freerun:56: error: ‘u201c’ was not declared in this scope
    freerun.ino: In function ‘char int2hex(int)’:
    freerun:65: error: lvalue required as left operand of assignment

    • Yeah, looks like the WordPress software kind of mangled the code when I pasted it into the comment. I went back and edited it, so try copying it again and see if that works better.

  5. Sorry, there seems to be something wrong with the sketch — for one thing, I don’t see a digitalRead() anywhere to pick up what the CPU is sending. Are you sure this is the correct code?

    Oh, and thanks for all the work!

  6. FYI I can confirm that the sketch will work with a 1 MHz clock can attached to the CPU as well. Just comment out the delay line to make it faster. Thanks again!

  7. Pingback: Make your own Apple 1 replica | Dave Cheney

  8. Note that without RAM, you can’t run a subroutine, even if it’s in ROM, as the return address is stored on the stack in RAM. You can have a minimal 6502 computer with only five ICs though, having uP, ROM, RAM, I/O, reset circuit, clock circuit, and address decoding. See http://wilsonminesco.com/6502primer/potpourri.html#BAS_CPU

    For a NOP generator, I like to recommend $A9 so you get LDA #$A9 because then you get one memory read per clock and one address advance per clock.

    Keep us posted. Are you on http://forum.6502.org/ ?

    I have a 6502 primer (and loads of other 6502 articles, links, etc., and lots more coming as time allows) at http://wilsonminesco.com/ .

    • Hey, thanks for your comment. Your primer is a great resource, and it was one of the things that inspired me to start this project – I know I refer to it in at least a couple of the P:65 posts.

      I’ve lurked on 6502.org, but I don’t tend to post much on forums lately. I really should swing by and say ‘hi’ one of these days 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s