Собственно, примерно так и было сделано, только вместо ПК8000 использована Arduino Mega2560.
У нее и частота поболе (16MHz) и входов побольше - можно сразу ША и ШД читать.
Да и удобней на ноутбуке прошивку править и заливать.
Вот, собственно исходник прошивки:
Код:
/*
Logic Analyser
Version 0.1
VWarlock, ALSP 2016
Connection:
PK8000 MEGA Description
X1.3 -> A0 D0
X1.4 -> A1 D1
X1.5 -> A2 D2
X1.6 -> A3 D3
X1.7 -> A4 D4
X1.8 -> A5 D5
X1.9 -> A6 D5
X1.10 -> A7 D6
X1.12 -> D20 ReadRAM
Pin 8 D5 -> D21 RESET
*/
//#define DEBUG 1
#undef DEBUG
//#define INTERRUPT 1
#undef INTERRUPT
const unsigned char traceLen = 255;
static char data[traceLen];
unsigned char traceIndex = 0;
bool enabled = false;
void Clock()
{
#ifdef DEBUG
Serial.println("Reset");
#endif
if (enabled)
{
//for (int i = 0; i < 3; i++); // Delay if needed
data[traceIndex++] = PINF;
if (traceIndex == traceLen)
{
enabled = false;
OutData();
}
}
}
void Reset()
{
#ifdef DEBUG
Serial.println("Reset");
#endif
traceIndex = 0;
enabled = true;
}
void ReadBUS()
{
while ( !(PIND & 0b00000010 )); // Waiting for RESET
while ( PIND & 0b00000010 );
for ( int i = 0; i < traceLen; i++ )
{
while (!(PIND & 0b00000001)); // Waiting for Clock (ReadRAM)
//for (int k = 0; k < 1; k++); // Delay if needed
data[i] = PINF; // Read BUS
while (PIND & 0b00000001);
}
OutData();
}
void OutData()
{
char buf[10];
Serial.println("\n\nStart");
for ( int i = 0; i < traceLen / 16; i++ )
{
sprintf( buf, "\n%04X: ", (int)( i * 16 ));
Serial.print(buf);
for ( int j = 0; j < 16; j++ )
{
sprintf( buf,"%02X ", (unsigned char) data[i * 16 + j]);
Serial.print(buf);
}
}
Serial.println();
}
// the setup routine runs once when you press reset:
void setup()
{
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
Serial.println( "----------------------------------------------------" );
// initialize MEGA ports:
DDRF = B00000000; // port F as input
DDRK = B00000000; // port K as input
#ifdef INTERRUPT
pinMode(21, INPUT_PULLUP); // PD0 Clock
pinMode(20, INPUT_PULLUP); // PD1 Reset
attachInterrupt( digitalPinToInterrupt( 21 ), Clock, FALLING);
attachInterrupt( digitalPinToInterrupt( 20 ), Reset, RISING);
#else
DDRD = B00000000; // port D as input
#endif
}
// the loop routine runs over and over again forever:
void loop()
{
#ifdef INTERRUPT
delayMicroseconds(1000);
#else
ReadBUS;
#endif
}
- - - Добавлено - - -
А вот и фото: