Monday, November 23, 2020

Reader of vintage PAL (next)

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.


This system uses a powerful Basic interpreter and allows easy use of files on SDcard.

To be able to physically read several types of PAL, I developed a small interface, based on the computer's I / O connector. The circuit is very simple and is based around the use of the SPI bus associated with a MCP23S17 type port expander from Microchip.


Nothing very complicated on this circuit. In fact, it is possible to obtain a printed circuit board of reduced size which connects directly to the port of the CMM2.


The PCB, once made and equipped with all the components, looks like this:


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.

Once this extension has been completed, and the first operational tests with the CMM2 computer validated, I was able to write the first program. In order to not complicate this first program, I deliberately 'restricted' its use to 10in / 8out type PAL, such as 10H8.

' 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
' -------------------------------------------------------------------------------------------------
(Sorry but there is no coloring class for the Basic language).
 
Again, there is nothing very complicated in this source. Please note that I am using the CMM2 via the USB serial port on my PC, equipped with the 'Tera Term' software. CMM2 also has the possibility of being used in exactly the same way, in complete autonomy, directly with a VGA screen and a USB keyboard. Graphical instructions can also be used to enhance the 'user experience'.


At the end, a file is generated in the form : 

Address                                                              Data
A09 A08 A07 A06 A05 A04 A03 A02 A01 A00    D07 D06 D05 D04 D03 D02 D01 D00

I did not generate a particular format, but it is still very easy to do from the Basic source, for example to use this data with the 'Logic Friday' utility, which allows the generation of the equations corresponding to these data.


Please do not hesitate to send me your comments :

No comments:

Post a Comment