snowsh
Well-known member
I am working on replacing a Z80 controller board in an analog recording console with a teensy replacement. The z80 board handles some input from switches and sets electronic switches.
I have sucessfully attached to the data busses. For now I am using an arduino Mega 2560 Rev 3 merely because I had one handy and it has plenty of pins.
Bus lines:
data 8 bits
address 11 bits
control lines 4 bits
I am now working on a new sketch to pump addresses in and attaching a jumper wire to the relevant CS pins on the hardware to sniff out addresses. This will help me build up a table of addresses to access each part of the console.
I know this is just a small part of what I am trying to acheive.
So my problem. I am trying to cycle through all possible addresses, 11 bits a total of 2048 addresses.
I have based this on an example @PaulStoffregen gave me for controlling MUX lines - https://forum.pjrc.com/threads/67322-cd74hc4067-16-channel-MUX-eyes-needed!?highlight=bit+fiddle
This code runs in a for loop incrementing j upto 2048:
my code then continues to print out the data direct from j:
I have made the assumption the technique of comparing j to its binary position, each time doubled is the correct approach, but I get odd results when using this "bit fiddle". Serial.print(j, BIN) however gives me the correct visualisation in serial monitor that I am expecting. What am I doing wrong? I want to be sure that my pins are outputting the correct address before I go further!
I have sucessfully attached to the data busses. For now I am using an arduino Mega 2560 Rev 3 merely because I had one handy and it has plenty of pins.
Bus lines:
data 8 bits
address 11 bits
control lines 4 bits
I am now working on a new sketch to pump addresses in and attaching a jumper wire to the relevant CS pins on the hardware to sniff out addresses. This will help me build up a table of addresses to access each part of the console.
I know this is just a small part of what I am trying to acheive.
So my problem. I am trying to cycle through all possible addresses, 11 bits a total of 2048 addresses.
I have based this on an example @PaulStoffregen gave me for controlling MUX lines - https://forum.pjrc.com/threads/67322-cd74hc4067-16-channel-MUX-eyes-needed!?highlight=bit+fiddle
This code runs in a for loop incrementing j upto 2048:
Code:
digitalWrite(ADDR[0], ((j & 0x01) ? HIGH : LOW)); // bit-fiddle to set the i-th pin to HIGH IFF binary version of j
digitalWrite(ADDR[1], ((j & 0x02) ? HIGH : LOW));
digitalWrite(ADDR[2], ((j & 0x04) ? HIGH : LOW));
digitalWrite(ADDR[3], ((j & 0x08) ? HIGH : LOW));
digitalWrite(ADDR[4], ((j & 0x16) ? HIGH : LOW));
digitalWrite(ADDR[5], ((j & 0x32) ? HIGH : LOW));
digitalWrite(ADDR[6], ((j & 0x64) ? HIGH : LOW));
digitalWrite(ADDR[7], ((j & 0x128) ? HIGH : LOW));
digitalWrite(ADDR[8], ((j & 0x256) ? HIGH : LOW));
digitalWrite(ADDR[9], ((j & 0x512) ? HIGH : LOW));
digitalWrite(ADDR[10], ((j & 0x1024) ? HIGH : LOW));
Serial.print(F("pin output:---- ")); // order reversed for visual
Serial.print((j & 0x1024) ? "1" : "0");
Serial.print((j & 0x512) ? "1" : "0");
Serial.print((j & 0x256) ? "1" : "0");
Serial.print((j & 0x128) ? "1" : "0");
Serial.print((j & 0x64) ? "1" : "0");
Serial.print((j & 0x32) ? "1" : "0");
Serial.print((j & 0x16) ? "1" : "0");
Serial.print((j & 0x8) ? "1" : "0");
Serial.print((j & 0x04) ? "1" : "0");
Serial.print((j & 0x02) ? "1" : "0");
Serial.print((j & 0x01) ? "1" : "0");
Serial.print(F(" ---- "));
my code then continues to print out the data direct from j:
Code:
Serial.print(F(" ----- "));
Serial.print(j, BIN);
Serial.println(F(" ----- "));
I have made the assumption the technique of comparing j to its binary position, each time doubled is the correct approach, but I get odd results when using this "bit fiddle". Serial.print(j, BIN) however gives me the correct visualisation in serial monitor that I am expecting. What am I doing wrong? I want to be sure that my pins are outputting the correct address before I go further!
Last edited: