Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
10Hz clock pulse generator / 13-bit monitor (for 6507 CPU)
// Turns an Arduino into a 10Hz clock generator and a monitor for a 13-bit address bus
//
// Based on David Barton's clock generator/monitor in http://www.plingboot.com/2015/10/homebrew-6502-part-2/
// (MIT License; full license information on footer)
// Pulse pin 13
#define CLOCK 13
// Read pins 0-12 as a 13 bit value from 6507's address bus
#define ADDRA 0
#define ADDRB 1
#define ADDRC 2
#define ADDRD 3
#define ADDRE 4
#define ADDRF 5
#define ADDRG 6
#define ADDRH 7
#define ADDRI 8
#define ADDRJ 9
#define ADDRK 10
#define ADDRL 11
#define ADDRM 12
void setup() {
pinMode(CLOCK, OUTPUT);
digitalWrite(CLOCK, LOW);
Serial.begin(9600);
}
void loop() {
delay(100);
// send clock output high
digitalWrite(CLOCK, HIGH);
// read value on lower half of address bus
byte a = digitalRead(ADDRA);
byte b = digitalRead(ADDRB);
byte c = digitalRead(ADDRC);
byte d = digitalRead(ADDRD);
byte e = digitalRead(ADDRE);
byte f = digitalRead(ADDRF);
byte g = digitalRead(ADDRG);
byte h = digitalRead(ADDRH);
byte i = digitalRead(ADDRI);
byte j = digitalRead(ADDRJ);
byte k = digitalRead(ADDRK);
byte l = digitalRead(ADDRL);
byte m = digitalRead(ADDRM);
word address_value = m << 12;
address_value += l << 11;
address_value += k << 10;
address_value += j << 9;
address_value += i << 8;
address_value += h << 7;
address_value += g << 6;
address_value += f << 5;
address_value += e << 4;
address_value += d << 3;
address_value += c << 2;
address_value += b << 1;
address_value += a;
// display value
Serial.print("Lower address bus : ");
Serial.print(m);
Serial.print(l);
Serial.print(k);
Serial.print(j);
Serial.print(i);
Serial.print(h);
Serial.print(g);
Serial.print(f);
Serial.print(e);
Serial.print(d);
Serial.print(c);
Serial.print(b);
Serial.print(a);
Serial.print(" : 0x");
Serial.print(address_value, HEX);
Serial.println();
digitalWrite(CLOCK, LOW);
}
// Copyright 2017 Carlos Duarte Do Nascimento (@chesterbr)
// Based on original work © David Barton (http://www.plingboot.com/2015/10/homebrew-6502-part-2/), under permission.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment