## Understanding how the “code switching” EPROM circuit works

projepromsw01.htm

For this article, we will use the 128K EPROM (27C128 used in the 1986 to 1989 IROC-Zs with the 1227165 ECMs) as the basis for our discussion.  This purpose of this article is to educate those on a little bit of binary and hexadecimal background, in order to understand what’s going on.

Binary numbers consist of 1’s and 0’s only.  1 = 1, 2=10, 3=11, 4=100, 5=101 and so on.  Here’s a simple charted example of one byte (8 bits) of data to explain better:

 128 8 64 4 32 2 16 1 8 4 2 1 1 0 1 0 1 0 1 1 A B

The binary number 10101011 equals 171 in decimal.  How did we do this?  We took the number 10101011 and entered the bits into the numbered chart (Going from right to left, start from 1 and double the value as you go left.  1, 2, 4, 8, etc. as shown on the top row.)  Then, wherever this is a 1 bit, add that number represented, then the next 1 bit and so on.  So we added 128+32+8+2+1 to equal 171.

What is 171 in hexadecimal?  Well, let’s leave it as binary.  Hexadecimal is a 16 number base system.  You would count 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, etc.  Take the right side of the chart above.  Add the 1’s together (8+2+1) = 11 in decimal, but B in hexadecimal.  Remember …9, A, B, C …represents 11 in decimal.  We would then do the same on the left side, but here’s the trick.  Use the SAME numbering convention as if you’re starting over on this section.  You would not use 128, 64, 32, 16.  Use 8, 4, 2, 1 again.  Add the 1’s together (8+2) = 10 in decimal, but A in hexadecimal.

So 171 = 10101011 in binary = AB in hexadecimal.  Yes, we could always use the scientific calculator in Windows, sure, but in order to understand how this code switching  works, take the time and convert some numbers to binary and hexadecimal.  Then VERIFY with calculator to see if you’re correct.

Let’s discuss the 128K EPROM chip, otherwise known as the 27C128 or equivalent.  This chip holds 16384 address points with 1 byte of data each.  1 byte equals 8 bits of data (binary numbers equal 1 bit of data), multiplied by 16384, you get 131072 bits (or 128K bits) of total memory.  Remember the 16384 address points.  The hexadecimal value of 16384 is 4000h (we will use h to signify that we are talking about a hexadecimal number).  On an EPROM chip, this would be addresses 0000h to 3FFFh.

There are 14 address lines in the 128K EPROM chip.  A0-A13.  Go ahead, figure that one out!  Addressing is done via binary.  Take the address lines and lets chart it out…

 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 F F F

If all of the address lines were set to 1, you would reach the last byte of the EPROM memory at 3FFFh.  If you wanted to access the byte at 2000h, the address lines would look like this:

 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0

A13 would be the only address line set to 1 to access address 2000h.

Now the good part.  Switching of the code on a larger EPROM (or EEPROM) chip.  Let’s use the 32-pin 27C010 chip, which is a 1-megabit chip.  We could fit 8 times the code on a 1-megabit chip of the 128K bit chip.  For this example, we’ll go ahead and put the same 128K code in the different sections of the 27C010 chip.  Code from 0000h to 3FFFh of the 27C128 would fit in 0000h to 3FFFh, 4000h to 7FFFh, 8000h to BFFFh, C000h to FFFFh, 10000h to 13FFFh and so on.  But how would we access the different “sections” of the larger chip?  How would the ECM know?  It doesn’t.  We’re going to “fool” the ECM into thinking it’s accessing the same data via it’s addressing scheme.  By manipulating the upper addresses (A14-A16 on the 27C010) manually, we can set the address to different (4000h at a time) sections via a switch of some sort.  Let’s see how this works … well, first off, the 27C010 uses 17 address lines (A0-A16)

 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 65536 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0

Since the 27C128 chip only has 14 address lines, Setting A14 to A16 to ‘0’ would accomplish the same feat.  ECM wants to access 0000h, it would get 0000h.  Theoretically, with an adapter, you could use a 27C010 chip and as long as the needed data resides at 0000h to 3FFFh, everything would be fine.

With a switch, we’re going to set A14 to ‘1’.  What does this do?  Changes the address dramatically.  If the ECM is wanting to access 0000h and we set the A14 address bit to 1, the ECM would get data in the 4000h to 7FFFh section of the EPROM chip.  Why?  Do the math … as above.  Set the A16 to A14 address section to ‘2.’  Which would be 010 (Looking at A16, A15 and A14 bits only).  That would set the address to 8000h.  Set the A16 to A14 address to ‘3’, which would be 011.  This sets A15 and A14 to ‘1.’  That hexadecimal number is adding 8+4 (see the section – sections will ALWAYS be in 4’s, regardless of where the “extra” addressing lines are).  This would set the address to C000h.

What’s next?  Setting A16 to ‘1’ and A15 to A14 to ‘0’ again would set the A16-A14 switch to a 100 binary numbering of ‘4.’  But wait, it’s a ‘new’ section.  Yep, but that doesn’t matter to the ECM.  The ECM still wants 0000h remember?  So lets do this.  Setting A16 to ‘1’ and the rest of the address lines to ‘0’ would result in a hexadecimal address of 10000h.   Confusing?  Well, look at address 8000h.  In this numbering scheme, with A16 set to ‘0,’ it’s the same as calling it 08000h.  Just to make it more understandable I suppose.

Keep going with it and you’ll see that no matter how you manipulate the bits for address lines A16 to A14, you are accessing data in the exact same spot, in 4000h address sections at a time. By setting the “extra” address lines to 111 via the switching, we would access address 1C000h to 1FFFFh.  Looking at the datasheet for the 27C010, we’re right on target.  It stores data between 00000h to 1FFFFh.  Perfect.  That’s 131,071 address points with 8 bits each, equals 1,048,568 bits or 1 mega-bit.

So you see, we are controlling where the ECM goes.  On the 1227165 ECM, it addresses 0000h to 3FFFh and that’s all it does.  By manipulating the address lines A16 to A14, what we’re doing is changing the address line values on the CHIP, not the ECM.  So if the ECM is looking for data at 0200h and we set the A16 to A14 switches from a 000 to 001, the ECM would get the data from 4200h.  As setting the bit to ‘1’ on A14 tells the CHIP that you want data from 4200h … whereas the ECM still thinks it’s data from 0200h.  We hope this is understandable.

Okay, brain, how do we do this in the real world … here’s where some electronics skills come into play, but someone has already done the work for you.  No, I cannot take credit for it, but I understand completely how it works.  This schematic was obtained from DYI-EFI file repository.  After looking over it, decided, this is a good idea.  The switching of address lines A16 to A14 will consist of switches (3) and resistors (3).  Simple.

Take a look at the above figure.  This is a simple switching circuit, attached to A14.  With the switch in the OPEN position, the A14 pin would receive Vcc (or +5V) and would set that address bit to ‘1.’  Closing the switch would pull Vcc to Ground, resulting on no voltage to the A14 pin and would result in setting that address bit to ‘0.’  Remember, CLOSING the switch would set it to ‘0’, opening to ‘1.’

If we wanted to “reverse” the switching to make “more sense,” we could use an inverter between the pin and switch.  Most common and readily available inverter is the 7404 Hex Inverter chip, which is a 14-pin dip chip that consists of 6 inverters that we can use.

Here’s a simple diagram showing the use of an inverter:

With the switch in the open position (off), the result out of the inverter, to pin A14, would be ‘0’ or low.  With the switch in the closed position (on), the result of out of the inverter, to pin A14, would be ‘1’ or high.

The choice is yours.  If using the type of DIP switch that when the switch is in the UP position is OFF, perhaps the diagram without the inverter would be the best choice.  The ‘piano’ type DIP switch is most common for this.  Using a binary number counter switch, the use of the inverter would be recommended.

Here’s a draft diagram of a completed circuit schematic.  Keep in mind, I only connected the Data and Address lines in the diagram.  You would still connect OE to OE, CE to CE and PGM (WE) to PGM.

Keep in mind that Vss is Ground.  Notice the switches, 1-3, are set up 1-3 and not 3-1.  It all depends how you want to design the circuit.  If using DIP switches, you may want to reverse the switches as 3-2-1.  That way, setting the switches to OFF-OFF-ON would equal 1, OFF-ON-OFF would equal 2, and so on.  But then again, OFF-OFF-OFF would set A14-A16 to high or ‘1.’  Since we’re not using an inverter in this circuit, you have to think opposite.  Setting them all to ON, would set all of them to ‘0.’  It is probably a little confusing, but not hard to get used to I suppose.

For the following diagram, I installed an inverter:

I used the same switch order, 1-2-3.  Perhaps, it would be better to go ahead and set these to 3-2-1.  In this circuit, you need to connect CE to CE, OE to OE and PGM to PGM (or WE to PGM – same thing) as well.  I just wanted to show you the schematic of connecting the address and data pins as well as Vcc and Vss (Ground).  In the above circuit, all switches to off is 000 (not 111 as in the diagram above this one).

Again, leaving the switch off, would leave a high level on the collector pin of the 7404 hex inverter chip.  The inverter would, in fact, invert the signal, from a high to a low (0 volts).  Seeming, that if my switch is OFF, I would want to have a low signal to the pin it’s affecting.  This is optional.  Whatever you do, make sure you’re on track with what and how you are doing it.

This is 100% theory and has NOT been tested.  I plan on testing this very soon.  It has been claimed that you can switch programs on the fly.  WE recommend that you do not switch on the fly.  Switching during the middle of data retrieval can be very harmful to your engine.  Let’s say you switch, right when the ECM as looking for a particular value for spark advance.  It’s supposed to be 20* but since you switched the program right in the middle, the data got corrupted and it receives the value to advance 50* instead!  I’m not saying it will happen, I just believe it’s highly probable.  Pull over, shut off the car, switch the program, start it back up.  Better safe than sorry.

Allan Reinike

### 4 Responses to “Understanding how the “code switching” EPROM circuit works”

1. Tom says:

Hello, awesome work.  I am designing a similar circuit for using a 2M chip where a 512K chip was, and switching between programs.  Have you considered grounding the switches to vehicle chassis ground?  Is that a bad thing?  If that is fine then it would mean one less wire into the PCM, as you dont have to run the ground wire all the way back.  Then I would just have a switch for each A16 and A17 to have up to four programs.
Also, I suppose this could be a logic thing, but in the circuit when you ground any of the three switches the easiest path to ground for the 5V will be to GND, so would you still have a logic high on the other two, or would this ground out all of the 5V to anything?  In a regular circuit I would switch between 5V and ground with a SPDT switch directly in-line.
Thanks.

2. ron says:

I WANT A CHIP TO HANDLE 450 TO500 HP

3. Tom says:

Normal
0

false
false
false

EN-US
X-NONE
X-NONE

MicrosoftInternetExplorer4

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:”";
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,”sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:”Times New Roman”;
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}

I really like this idea.  Have you tried it yet?
I am not sure about your notting circuit.  I wonder what would happen on startup.  If it talks longer for the dip switches to be notted than it does for the computer to read the memory location you could get a strange error.  Granted, the inverter would almost certainly start up faster than the EPROM.  I think a simpler solution would be to use a STDP switch.  The second pole could be used as a normally closed dipswitch.  They are available at mouser.com.

4. Cliff Harris says:

When you turn on the ignition switch, there is a chip in the ECM that holds the CPU in reset until the power is stable.  The switch/pullup resistors will have done their thing long before the CPU starts executing the instructions in the EPROM.