summaryrefslogtreecommitdiff
path: root/sketches
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2020-11-17 19:12:00 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2020-11-17 19:12:00 +0100
commit63d0944063b6f240fe0c68ef9b61d4dd906d9fc1 (patch)
treefb083c1284fd6d58944b1961297c652dc32b515d /sketches
download6502-63d0944063b6f240fe0c68ef9b61d4dd906d9fc1.tar.gz
6502-63d0944063b6f240fe0c68ef9b61d4dd906d9fc1.tar.bz2
initial checkin
Diffstat (limited to 'sketches')
-rw-r--r--sketches/6502_addr_read.ino48
1 files changed, 48 insertions, 0 deletions
diff --git a/sketches/6502_addr_read.ino b/sketches/6502_addr_read.ino
new file mode 100644
index 0000000..415c4b7
--- /dev/null
+++ b/sketches/6502_addr_read.ino
@@ -0,0 +1,48 @@
+char addr_pin[16];
+char data_pin[8];
+const int clock_pin = 2;
+const int rw_pin = 3;
+
+void setup( )
+{
+ for( int i = 0; i < 16; i++ ) {
+ addr_pin[i] = 52 - i*2;
+ pinMode( addr_pin[i], INPUT );
+ }
+ for( int i = 0; i < 8; i++ ) {
+ data_pin[i] = 53 - i*2;
+ pinMode( data_pin[i], INPUT );
+ }
+ pinMode( clock_pin, INPUT );
+ pinMode( rw_pin, INPUT );
+ attachInterrupt( digitalPinToInterrupt( clock_pin ), onClk, RISING );
+ Serial.begin( 115200 );
+}
+
+void onClk( )
+{
+ unsigned int addr = 0;
+ for( int i = 0; i < 16; i++ ) {
+ int b = ( digitalRead( addr_pin[i] ) == HIGH ) ? 1 : 0;
+ Serial.print( b );
+ addr = ( addr << 1 ) + b;
+ }
+ Serial.print( " " );
+ unsigned int data = 0;
+ for( int i = 0; i < 8; i++ ) {
+ int b = ( digitalRead( data_pin[i] ) == HIGH ) ? 1 : 0;
+ Serial.print( b );
+ data = ( data << 1 ) + b;
+ }
+ Serial.print( " " );
+
+ char rw = ( digitalRead( rw_pin ) == HIGH ) ? 'r' : 'w';
+
+ char output[32];
+ sprintf( output, "%04x %c %02x", addr, rw, data );
+ Serial.println( output );
+}
+
+void loop( )
+{
+}