As I presented in a previous post, I wanted to make a small application capable of reading old PLDs in a simple way. I didn't want to venture into creating a controllable USB interface with a PC. Too complicated and too time consuming, especially with Windows programming. I could have used an Arduino-based system as well, but the DIY 'side' didn't really inspire me. I preferred to use a more 'serious' system. So I decided to use the powerful COLOR MAXIMITE 2 microcomputer as a base.
The PCB is fairly easy to build despite a few surface mount components. I am thinking of putting this small development in open access but have not yet decided in what form.
' PAL READER CONFIGURATION : 10 INPUTS, 8 OUTPUTS
' -----------------------------------------------------------------------------
' Signals defines
CONST CS = 27 ' /CS for the MCP
CONST C0 = 29 ' PIN no 1
CONST C1 = 31 ' PIN no 11
CONST RST = 33 ' /RST for the MCP
CONST PWR = 7 ' Power signal for the board
CONST DLY = 1 ' Value of temporisation for SPI chronos
'
' Abstract for the PAL
' --------------------
' PIN no 1 : C0 (I)
' PIN no 2 : A7 (I) [BUS GPAx of the MCP]
' PIN no 3 : A6 (I) //
' PIN no 4 : A5 (I) //
' PIN no 5 : A4 (I) //
' PIN no 6 : A3 (I) //
' PIN no 7 : A2 (I) //
' PIN no 8 : A1 (I) //
' PIN no 9 : A0 (I) //
' PIN no 11 : C1 (I)
' PIN no 12 : B7 (O) [BUS GPBx of the MCP]
' PIN no 13 : B6 (O) //
' PIN no 14 : B5 (O) //
' PIN no 15 : B4 (O) //
' PIN no 16 : B3 (O) //
' PIN no 17 : B2 (O) //
' PIN no 18 : B1 (O) //
' PIN no 19 : B0 (o) //
'
' Globales variables init
TYPE$ = "10IN 8OUT"
ADDR_X = 1023 ' 1024 possibilities
PORT_A = &B00000000 ' GPBA => OUTPUT
PORT_B = &B11111111 ' GPBB => INPUT
FILE_$ = "Pld type: " + TYPE$ + " at: " + DATETIME$(NOW)
' Signals configuration and INIT.
'
' *** IMPORTANT : Respect the order of this sequence ***
'
SETPIN PWR, DOUT : PIN(PWR) = 0
SETPIN RST, DOUT : PIN(RST) = 0
SETPIN CS, DOUT : PIN(CS) = 0
SETPIN C0, DOUT : PIN(C0) = 0
SETPIN C1, DOUT : PIN(C1) = 0
' Display home page
PRINT "********************************************"
PRINT "* PAL READER V1.0 *"
PRINT "* *"
PRINT "* BE SURE TO CONNECT THE INTERFACE FIRST ! *"
PRINT "* *"
PRINT "* Copyright SillyCony 2020. *"
PRINT "* *"
PRINT "* "+TYPE$+" *"
PRINT "* *"
PRINT "********************************************"
' Wait for keystroke
PRINT : INPUT "Press 'ENTER' to start when ready"; Misc : PRINT
' Start of the process
' Open file. If existe : overwrite the file
OPEN TYPE$ + ".pld" FOR OUTPUT AS #1
' Powering the board : *** respect the sequence ***
PIN(PWR) = 1 : PIN(CS) = 1 : PIN(RST) = 1
' Open the SPI PORT at 3.125MHz, MODE 0:0, ONE byte
SPI OPEN 3125000, 0, 8
' MCP23S17 configuration
McpConfig
' Reading loop
PRINT "-> Reading... "
DO WHILE ADDR_X
PRINT ".";
' Configure all the signals for the PAL
Port_A_Out : Port_B_Out : Port_C_Out
' Write in file the PAL return
PRINT #1, BIN$(ADDR_X, 10) + " " + BIN$(Port_B_In(), 8)
' Next 'address'
ADDR_X = ADDR_X - 1
LOOP
' Write Date & Time
PRINT #1, "" : PRINT #1, FILE_$ : PRINT #1
' Close the file
CLOSE #1
' Message
PRINT : PRINT : PRINT " -> Reading terminated. ";
' Shutdown the board: *** respect the sequence ***
PRINT "Shutdown the board."
SPI CLOSE : PIN(C0) = 0 : PIN(C1) = 0 : PIN(RST) = 0 : PIN(CS) = 0 : PIN(PWR) = 0
' Programm END
' -------------------------------------------------------------------------------------------------
FUNCTION Port_B_In() AS INTEGER
LOCAL Misc
PIN(CS) = 0 : PAUSE DLY
Misc = SPI(&B01000001) : Misc = SPI(&H13) : Port_B_In = SPI(&H13)
PIN(CS) = 1 : PAUSE DLY
END FUNCTION
' -------------------------------------------------------------------------------------------------
SUB Port_A_Out
LOCAL Misc
Misc = ADDR_X AND &B0111111110 : Misc = Misc / 2
PIN(CS) = 0 : PAUSE DLY
SPI WRITE 3, &B01000000, &H14, Misc
PIN(CS) = 1 : PAUSE DLY
END SUB
' -------------------------------------------------------------------------------------------------
SUB Port_B_Out
LOCAL Misc
Misc = ADDR_X AND &B000000000
IF Misc <> 0 THEN
PIN(CS) = 0 : PAUSE DLY
SPI WRITE 3, &B01000000, &H15, Misc
PIN(CS) = 1 : PAUSE DLY
ENDIF
END SUB
' -------------------------------------------------------------------------------------------------
SUB Port_C_Out
LOCAL Misc
Misc = ADDR_X AND &B0000000001
IF Misc = 0 THEN : PIN(C1) = 0 : ELSE : PIN(C1) = 1 : ENDIF
Misc = ADDR_X AND &B1000000000
IF _DataTemp = 0 THEN : PIN(C0) = 0 : ELSE : PIN(C0) = 1 : ENDIF
END SUB
' -------------------------------------------------------------------------------------------------
SUB McpConfig
' Force Chip Address to 000
PIN(CS) = 0 : PAUSE DLY
SPI WRITE 3, &B11110001, &H0A, &B00001000
PIN(CS) = 1 : PAUSE DLY
' CONFIGURE PORT A
PIN(CS) = 0 : PAUSE DLY
SPI WRITE 3, &B01000000, &H00, PORT_A
PIN(CS) = 1 : PAUSE DLY
' CONFIGURE PORT B PULL UP by default
PIN(CS) = 0 : PAUSE DLY
SPI WRITE 3, &B01000000, &H0D,&HFF
PIN(CS) = 1 : PAUSE DLY
' CONFIGURE PORT B
PIN(CS) = 0 : PAUSE DLY
SPI WRITE 3, &B01000000, &H01, PORT_B
PIN(CS) = 1 : PAUSE DLY
END SUB
' -------------------------------------------------------------------------------------------------