M68hc08 Serial Programmer Schematic
Originally published by Paul Stenning in ETI, January andFebruary 1993.There has long been a requirement for a cheap straight-forwardEPROM Programmer, suitable for occasional home use, without theextra features found on many commercial units. The EPROM Programmerpresented here will program the standard 27 family of devices, from2716 to 27512, and can be used with any computer which has an RS232serial port. I have avoided the usual 'Catch 22' situation ofrequiring a programmed EPROM to make the EPROM programmer work!This design uses readily available components to reduce thelikelihood of obsolescence.The unit is powered from an external PSU, since this is cheaperthan buying the individual parts! One of the low cost unregulatedtypes with an integral mains plug is suitable, providing it iscapable of supplying between 10 and 18 Volts DC at 500mA withouttoo much ripple, the voltage regulator U21 will run cooler if thevoltage is nearer the lower end of this range. The types sold forpowering electronic keyboards appear to be the most suitable. Theprototype is powered by an old Sinclair ZX81 PSU (type UK1200).The programmer itself is dumb and is fully controlled by thehost computer via the serial port.
Control software can be writtenin BASIC, and a suitable listing for IBM PC compatible computers isgiven later. Additional software listings are given for initialtesting, and to convert to and from standard Intel-HEX files. Adisk is available from the author (downloadable as a zip file fromthis website), containing these programs, as well as comprehensivemenu driven control software and a few useful utilities.Please note that the programming algorithms used may not beexactly as specified in some EPROM manufacturer's data sheets.Because of this the unit cannot be guaranteed to program everydevice successfully, however no problems have been experienced todate.Circuit Operation.The circuit may appear complicated initially, however it comprisesof several relatively straight-forward sections. It is notnecessary to understand the operation of the circuit to build andoperate the unit with the software given, however a goodunderstanding is most useful if you wish to write your own controlsoftware.Note that when a number is followed by an 'h' in the followingdescription, for example 27h, it is a hexadecimal number, and whena number is followed by a 'b' it is binary, other numbers aredecimal.
Any signal name which is followed by a '-', for exampleSTROBE-, is active low, on the circuit diagram this will be shownwith a bar over the name.Useful information on EPROM pin-outs and programmingrequirements can be found on pages 498-499 of the 1993 Maplincatalogue, the project was designed around this data (note that theMaplin programming information for the 2732 is incorrect).U2 and surrounding components generate the Baud Rate clocksignal (CLOCK1) for U3, with the rate selectable by LK1. The CLOCK2signal is used to produce the programming timing pulses, see later.U3 is a CDP6402 (Maplin QQ04E) 'Universal AsynchronousReceiver/Transmitter' (UART). In this application it is configuredfor 8 data bits, 1 stop bit, no parity checking. Note that unusedpin 2 is taken low, this pin is used on the RCA CDP1854 to selectstandard operation mode, this device is otherwise pin compatiblecan therefore be used in place of the 6402. U3 is reset by U4:A andassociated components.When serial data is received on pin 20 of U3, it is converted toa parallel output on pins 5-12 (R0-R7), and pin 19 goes high. Ashort time later (set by R4 and C8) pin 18 is taken low, whichclears the high on pin 19.
The pulse so generated on pin 19 isreferred to as the STROBE signal, and indicates to other parts ofthe circuit that data has been received and is valid.If pin 23 of U3 (SEND) is pulsed low, data on pins 26-33 (D0-D7)is transmitted in serial form on pin 25. U1 is the serial line driver/receiver, which converts RS232standard serial signals to/from standard 5V TTL levels. This ICcontains voltage convertors to produce the required transmissionvoltages (+/- 9V) from a single +5V supply.In this application the 8 bit received data is used as 4 databits on R0-R3 and 4 control bits on R4-R7. 3 of these control lines(R4-R6) are taken to a '3 To 8 Line Decoder', U5. The STROBE signalis taken to one of the Enable lines on U5, thereby causing theoutputs from this IC to be short pulses. For example, if 00h isreceived, lines R4-R6 will be low, STROBE will pulse high andconsequently pin 15 of U5 will pulse high and the remaining outputswill stay low.The remaining control bit (R7) controls the power to the EPROM,when it is high all power is removed from the EPROM socket so thedevice can be inserted or removed. When the device is being read orprogrammed this line is taken low.The 4 data lines are taken to the inputs of 4 'Quad D-TypeLatches', U6-U9.
The Latch Enable lines on these IC's are connectedto 4 of the outputs of U5 (Y0-Y3). Data can therefore be stored inthese latches by sending the required data on lines R0-R3 and thelatch number (0-3) on lines R4-R6. The data will be continuouslyavailable on the latch output lines. Referring back to the previousexample, if 00h is received, lines R0-R3 will all be low, and lineY0 will pulse high, storing 0h (0000b) in U6. Similarly sending 35hwill store 5h (0101b) in U9Latch U6 is used to hold the least significant nibble (4 bits -half a byte) of the data which will ultimately be programmed intothe EPROM, whilst U7 holds the most significant nibble.
U8 holdsthe EPROM type information (see later), and U9 holds 4 setup bits.Bit 1 of U9 controls whether the unit is in Read or Write (Program)mode, bit 2 sets the programming pulse length to either 1 or 40milliseconds, bit 3 sets the programming voltage to either 12 or 21volts, and bit 4 sets the supply voltage whilst programming toeither 5 or 6 volts. Note that the latches have active-high andactive-low outputs, and one or both may be used.The data outputs from U6 and U7 are taken to a tri-state buffer(U10), which in turn drives the EPROM data lines. U10 is controlledby the R/W- line, such that it's outputs are enabled in Programmode and tri-state in Read mode.The EPROM data lines are also connected to the data input lineson the UART (U3), and the Y7 output from U5 is connected to pin 23of U3 (SEND). Therefore if 70h is received, the data currently onthe EPROM Data Lines is transmitted back along the serial interfaceto the computer.The EPROM Address lines are controlled by counters U11 and U12.These are connected to lines Y4 and Y5 from U5, and are thereforecleared to 0000h by sending 40h and the count is incremented bysending 50h. This approach is quicker than having to send theactual address each time since it only requires one byte to be sentalong the serial link.Line Y6 from U5 (PROG) is used to start a programming pulse.
Theprogramming pulse (either 1mS or 40mS) is produced by dividing downthe CLOCK2 signal. This signal has a frequency of 19.2KHz(2.4576MHz divided by 128), which equates to a period of 52.1uS.This is fed to counter U13, which is normally held reset by theSet/Reset flip-flop built from U15:C and U15:D. When the PROG linepulses high the flip-flop changes state and the counter startscounting the CLOCK2 pulses. If a 1mS pulse is required, pin 5 ofU14:A will be high and pins 12 and 13 of U14:B will be low. Whenthe count reaches 19 (52.1uS x 19 = 989.9uS), all the inputs ofU14:A will be high, it's output will therefore go low, changing thestate of the flip-flop again, via U16:B, and resetting the counter.A 0.99mS pulse will therefore be present on the output of theflip-flop, 0.99mS being well within the 1mS +/- 5% specification.If a 40mS pulse is required U13 counts 768 CLOCK2 pulses (52.1uS x768 = 40.01mS).The PROG PULSE and STROBE signals are coupled via U18:A and U1to the RS232 CTS (Clear To Send) line. This prevents the hostcomputer from sending further data whilst a program pulse isoccurring or while STROBE is still high.
This means that data canbe sent as fast as possible and no delays are needed in thesoftware.PROG PULSE- is coupled with the SEND signal to U3 by U16:A. Thisprevents the SEND signal getting through whilst PROG PULSE- is low.This situation will never occur in normal use, however duringinitialisation the software requests a 40mS program pulseimmediately followed by a SEND. If the RS232 CTS line is presentand working then data will be sent, since the CTS line will stopthe computer sending the SEND request until after the prog pulsehas finished. If CTS is not working the SEND request will be sentimmediately but no data will be returned due to U16:A stopping theSEND pulse reaching U3. The software notes the lack of receiveddata, prints a warning and then adds delays itself to allow for theprogram pulse. You should try to get CTS working properly as therewill be a significant speed penalty otherwise.
We now come to the connection switching required for thedifferent EPROM types. The table below shows the pin-outs for the 6types of EPROM this unit will program. 2716 and 2732 are 24 pindevices and fit into pins 3 to 26 of the EPROM socket, the pin-outsshown below relate to the socket, not the device. The four MODE lines from U9 control the function of these sixpins and are set up by the software to suit the EPROM typerequired. Note that two of the active-low lines are also used.
Thetable below shows the logic levels on each of these lines, for eachof the 6 types of EPROM, together with the code that needs to besent to select that type. EPROMMODE LINESETUPTYPEABCC-DD-CODE2Fh81106100200010120hI will now describe what this means for each type of EPROM.2716:PIN 1 - not used.PIN 20 - MODE B and MODE D are both high, so U17:B pin 6 remainshigh, U16:C pin 8 follows PROG PULSE, as does U17:C pin 8 which iscoupled via D6 to PIN 20.
PIN 20 is only pulled up in Program mode,so in Read mode it is permanently low.PIN 22 - MODE A and MODE D are both high, so U15:B pin 6 is lowand Q1 and Q2 remain off. R-/W is coupled to the pin via D2.PIN 23 - MODE D is high, so Q5 and Q6 are on, coupling VPP toPIN 23.PIN 26 - MODE C is high, so Q7 and Q8 are on, coupling V+ to PIN26.PIN 27 - not used.
2732:PIN 1 - not used.PIN 20 - MODE B and MODE D are both low. U16:C pin 8 will remainlow and U17:B pin 6 will follow PROG PULSE.
U17:C pin 8 willtherefore be PROG PULSE inverted, and is coupled via D6 to PIN 20.PIN 20 is only pulled up in Program mode, so in Read mode it ispermanently low.PIN 22 - MODE D and MODE C- are both low and MODE A is high, soU15:B pin 6 is high. This switches on Q1 and Q2, coupling VPP toPIN 22PIN 23 - MODE D is low, so Q5 and Q6 remain off. A11 is coupledto PIN 23 via D4.PIN 26 - as 2716.PIN 27 - not used.2764 and 27128:PIN 1 - MODE A is high.
This switches on Q3 and Q4, coupling VPP toPIN 1.PIN 20 - MODE B is high and MODE C is low. U16:C pin 8 remainslow and U17:B pin 6 remains high, thereforeU17:C pin 8 remains low.PIN 22 - MODE A and MODE C- are both high, so U15:B pin 6 is lowand Q1 and Q2 remain off. R-/W is coupled to PIN 22 by D2.PIN 23 - as 2732.PIN 26 - MODE C is low so Q7 and Q8 remain off. A13 is coupledto PIN 26 by D5. Note that in a 2764 EPROM there is no connectionto PIN 26.PIN 27 - MODE B is high and A14 will remain low since it isoutside the addressing range. U17:D pin 11 will therefore followPROG PULSE.27256:PIN 1 - as 2764.PIN 20 - as 2732.PIN 22 - as 2764.PIN 23 - as 2732.PIN 26 - as 2764.PIN 27 - MODE B is low so U16:D pin 11 will remain low.
U17:Dpin 11 will follow A14. 27512:PIN 1 - MODE A is low so Q3 and Q4 will remain off. A15 is coupledto PIN 1 by D3.PIN 20 - as 2732.PIN 22 - MODE A is low so U15:B pin 6 will be high, switching onQ1 and Q2, coupling VPP to PIN 22.PIN 23 - as 2732.PIN 26 - as 2764.PIN 27 - as 27256.Note that D6 and D7 are germanium types, since silicon typeswould cause the logic 0 inputs to the EPROM to be at the limit ofthe specifications.The two logic gates which would otherwise be unused, are used tocontrol Read and Program LED's. U18:B pin 6 goes low when R-/W andON-/OFF are both low, lighting D9 (Read) via Q10, whilst U18:C pin8 goes low when R/W- and ON-/OFF are low, lighting D8 (Program) viaQ9. When both LED's are off it is safe to fit or remove the EPROM,the other lines would have been set low by the software beforetaking ON-/OFF high.U21 is the main 5 Volt regulator and powers all the logic IC's.D11 protects the whole circuit against reverse polarity, since itis easily possible to reverse the polarity on the sort of PSU used.LED D10 indicates that the unit is powered up.U20 supplies the power to the EPROM, and is enabled by theON/OFF- line via Q17 and Q18. Q19 raises the GND pin of U20 by 1Volt, giving 6 Volts.
When 5 Volts is required Q19 is shorted outby Q20 controlled by U18:D, this happens when 5V/6V- or R/W- islow.U19 is a step-up switching regulator which produces theprogramming voltage required. The voltage is set by shorting outsections of the resistor chain with transistors.
2716 EPROMsrequire 25 Volts, not 21 Volts, so the MODE D- line is used to setthis. The R-/W line controls Q15 and Q16 which connect the power tothe EPROM when the unit is in Program mode. ConstructionThe construction of this PCB is rather fiddly and great care shouldbe taken.
All the components except the power input socket (SK2)and the RS232 socket (SK3) are mounted on the PCB. This is a doublesided board, about 210 X 88mm in size. Note that the holes in thePCB are not plated through. The PCB overlay is shown in figure ##Due to the complexity of the PCB, the construction should becarried out in the following order.Firstly enlarge U20 and U21 mounting tab holes, L1 mounting holeand the corner fixing holes to 3mm. Also enlarge the holes forpresets RV1-4 to 1.2mm, and the holes for U20, U21, D11 and theVeropins to 1.0mm.Next fit the through-board connections in the positions markedwith a single small circle on the overlay, there are 121 in total.Tinned copper wire should be used here, suitable pins may beavailable but check they will fit the holes in the PCB (0.8mm)before ordering. Now fit the transistors, resistor network andnon-polarised capacitors. The resistor network must be fitted thecorrect way round as shown on the overlay.
Note that many of thecomponent leads will also need to be soldered on the top of the PCB- wherever there is a pad it should be soldered to. This alsoapplies to the resistors, diodes and presets which can now befitted. Note that the presets can be fitted on the back of the PCBif required, this may ease adjustment once the PCB is mounted inthe case.Next fit all the DIL IC's except U3 and U19. Note that sincemany connections need to be soldered on the top of the PCB it isnot possible to use conventional IC sockets, although some of themore expensive turned pin types may be suitable.
IC sockets shouldnow be fitted in positions U3, U19 and SK1.It is now possible to fit the remaining components in anyconvenient order. Temporarily solder the LED's at the full lengthof their leads, and adjust them later when the PCB is being fittedin the case. L1 should be mounted with an M3 nut, bolt andshake-proof washer (do not over-tighten) or a dab of glue.
U20 andU21 should be mounted with M3 nuts and bolts, U21 would benefitfrom a small heatsink or bracket of some sort. Veropins should befitted for the off-board connections.
Fit a wire link in LK1position, between the lower two homes for 9600 baud, or as shown onthe overlay for other rates.TestingThe PCB should be tested before fitting into the case. Do not fitU3 or U19 yet. Connect the unit to a power supply via a test meterset to 500mA DC or greater. Switch on and watch the meter, if thereading exceeds 200mA switch off immediately and find out why! Makea note of this current. If all is well remove the meter and connectthe power directly. Now set the meter to 10V DC or thereabouts andcheck VCC on the power pins of one of the TTL IC's, this should bebetween 4.75V and 5.25V.
Also check for about +9V on pin 2 of U1and about -9V on pin 6 of U1.If you have a 'scope, look at the DC input and check that thetroughs of any ripple do not go below 10V. If there is significantripple from the power supply (greater than about 1V pk-pk), tryconnecting a 1000uF 25V capacitor directly across the DC input.You could now fit the remaining IC's, adjust the voltages, andtry the unit in use - and probably get away with it! However Iwould strongly urge that the following step-by-step checks arecarried out to ensure the unit is fully functional. A 'scope orlogic probe would be most useful, although most of the checks canbe done with just a test meter.If you have an IBM PC or compatible, start BASICA or G.W.BASIC(or QBASIC if you have MS-DOS 5), and enter the test program givenin Listing 1 (if you have obtained the disk from the author simplyrun TEST1.EXE, which is the compiled version). If you have adifferent computer you may have to modify or re-write the programas necessary, the notes in the 'How it Works - Software' sectionmay be of some help. It may be worth trying to get access to a PC,to avoid having too many unknowns!Insert U3 (the 6402), connect the programmer to the computersRS232 serial port (see fig ##), switch it on and then run thesoftware.
The software does nothing more exciting than wait for youto enter a 2 digit hex number (followed by ) and thensends it to the programmer. It then attempts to read back a number,if it's successful it prints the number otherwise it prints. Toexit just press on it's own.Type 'FF' (don't type the quotes, and follow it with). Check the logic levels on pins 5 to 12 of U3, theyshould all be logic 1. Note that logic 1 is anything over 3.5V andlogic 0 is anything under 0.5V. Now type '00' and the logic levelsshould all be 0. To be certain, type '55' and the levels should be01010101, then type 'AA' and the levels should be 10101010.
If youhave a 'scope or logic probe check for a short positive going pulseon pin 19 whenever a number is sent.The most likely cause of problems here is the RS232 wiring. Areyou using the right port (COM1) on your PC? You can edit line 70 ofthe program if you are using a port other than COM1.
Have you setLK1 to 9600 (or lower if your type of computer won't work at 9600)?Try swapping wires 2 and 3 in the RS232 lead. If the programappears to lock try disconnecting the CTS wire (Ctrl-Break willstop the software in this case).
Check the link settings on yourserial communications port - if you have the 'Everex EV170 MagicI/O Card' (used in many early XT and 286 AT machines) and can't getit to work, write to the author! Type '0F' and check pins 9, 10, 15 and 16 of U6, they should allbe at logic 1.
Now type '00' and they should all be at logic 0.Typing '05' should give 0101 and '0A' should give 1010. Now repeatthe above, replacing the first character with a '1' and checkingthe levels on U7, then '2' and U8, and finally '3' and U9.Now type '00', '10', '30' then '70'.
After you typed the '70'the screen should show '00', the others should have given '.' . The'Program' (red) LED should also be on. This set '00' on the databus, selected write mode to enable U10, then read the data backdown the RS232 link. The most likely cause of problems here is theRS232 link again.Now type '31' then '70'. The screen should show 'FF' and the'Read' (yellow) LED should be on. U10 is now disabled so it'soutputs are tristate and pulled up by RN1.Typing '30' then '70' should return '00' again.
Typing '0F','1F' then '70' should return 'FF', typing '05', '15' then '70'should give '55', and typing '0A', '1A' then '70' should give 'AA'.Also check that the appropriate data is actually reaching the EPROMsocket pins as shown below: Data LineD7D6D5D4D3D2D1D0Socket Pin131211TypeExpected LogicLevel'00', '0'05', '1'0A', '1A'10101010'0F', '1F'11111111Now we come to the address bus. Type in the program given inListing 2 (save the other program first as it will be neededagain). The program configures the programmer for 27512 EPROM's soall 16 address lines are bought to the EPROM socket and should bechecked there. The program clears the address counter and thenrepeatedly increments the count, pausing at selected points toenable the checks to be made.The logic levels should be checked on the pins of the EPROMsocket when the program pauses, if a level is incorrect check onthe appropriate pin on U11 or U12, then trace the fault asnecessary.
Note that the program may run quite slowly. A compliedversion (TEST2.EXE) which runs considerably faster is on the diskavailable from the author.Now re-load the first test program. Connect a 'scope or logicprobe to U15 pin 11.
Now when you type '60' you shouldobserve a 40 millisecond positive going pulse. Move the probe topin 8 of U15 and the pulse should be negative going. Now type '32'and repeat the above checks, the pulse should now be 1 millisecond.With a logic probe you will probably only be able to detect thepresence of the pulse and will have to assume it is the correctlength, with a test meter you probably won't be able to seeanything!Now switch off and insert U19.
Connect a test meter set to about500mA DC in line with the power input and switch back on. If thecurrent is more than 100mA greater than it was before switch offand find out why! The most likely cause is a short circuit on VPPsomewhere. If all is well remove the meter and connect the powerdirectly. Set all four presets to the centre position.Set a test meter to the 10V DC range and connect between pins 28(+ve) and 14 (-ve) of the EPROM socket. Type '23' then '38', themeter should read 5V +/-0.25V.
Now type '30' and the reading shouldrise, adjust RV1 for a reading of 6.1V +/-0.1V. Type '80' and thevoltage should drop to zero.
Set the meter to the 30V DC range andtransfer the +ve meter probe to pin 1 of the EPROM socket. Type'34' and then adjust RV2 for a reading of 12.6V +/-0.1V. Type '30'and adjust RV3 for 21V +/-0.25V. Type '2F' and adjust RV4 for 25V+/-0.25V. Type '31' and the voltage should drop to zero.The only thing left to check now is the various configurationsfor the different types of EPROM's. As described in 'How it Works',the functions of six of the EPROM socket pins vary depending uponthe type of EPROM. The address lines have already been checked atthe EPROM socket, as has the programming voltage to pin 1.
Thechecking of the remaining combinations is detailed below. Type '40' to clear the address counters. Connect a 'scope orlogic probe to pin 20 of the EPROM socket. Type '30' then '2F'. A40 millisecond positive going pulse should be observed when '60' istyped. Type '20', and the pulse when typing '60' should now benegative going. Now type '23' and the line should remain at logic 0when '60' is typed.
Move the probe to pin 22. Type '2F' then '31'and the line should be at logic 0. Type '30' and it should go tologic 1. Now type '20' and it should rise to 21V. Move the probe topin 23 which should be at logic 0. Type '2F' and the line shouldrise to 25V.
Move the probe to pin 26, which should be at 6V. Type'20' and it should go to logic 0. Finally move the probe to pin 27and type '23'. A 40 millisecond negative going pulse should be seenwhen you type '60'.If you have reached the end of all this successfully you can beconfident that your EPROM programmer is 100% functional!The Case.The prototype was mounted in a plastic case (type MB6) havingexternal dimensions of 220 X 150 X 64mm.
The removable panel isconsidered to be the bottom, and may be fitted with self-adhesivefeet if required. The top surface needs cut-outs for the EPROM ZIF(Zero Insertion Force) socket and the LED's, as well as four fixingholes for the PCB. You may also wish to make four small holes toenable adjustment of the presets.The rectangular cut-out for the ZIF socket may be made bydrilling a line of shall holes around the edge then breaking outthe centre part and filing to shape. Take care not to file the holetoo large or the result will look untidy! The socket is raisedabove the PCB by stacking up a number of 28 pin DIL IC sockets,three were used on the prototype. If the result feels insecure, thesockets may be held together with a suitable adhesive.Position the PCB and mark the positions of the four fixing holesand then measure the positions of the three LED holes.
The firstLED is 4mm down and 6mm to the left of the top right fixing hole(view from outside the box), the other two are spaced below at 9mmintervals. The fixing holes are 3mm in diameter whilst the LEDholes are 5mm. Also drill suitable holes in the rear of the casefor the DC input socket and the RS232 cable or connector. On theprototype a 3.5mm jack socket was used for power (since thismatched the plug on the PSU), and the RS232 cable passed through ahole fitted with a grommet. Choose connectors that are not likelyto come unplugged accidentally! The case may now be marked withrub-down transfers or similar if required.Solder suitable lengths of wire to the PCB for the off-boardconnections and insert the LED's through the holes in the PCB (donot solder yet). Mount the PCB in the case using M3 screws, nutsand spacers, then position the LED's so that they slightly protrudethrough the holes and solder them into place.
Complete theinterwiring (see Fig ##) and assemble the case. If an additionalsmoothing capacitor was found necessary whilst testing, this may bemounted across the pins of the DC input socket, or on the rear ofthe PCB in parallel with C21.Software Description.The following information describes the operation of the softwareshown in Listing1, Listing 2 and Listing 3 (these listings areincluded in the software download).In the following section a reasonable understanding ofprogramming in BASIC is assumed. The software was written forMicrosoft BASICA, as supplied with Compaq DOS 3.31. It has alsobeen tested with QBASIC supplied with MS-DOS 5 and with MicrosoftQuickBASIC V4.5. Users of other BASIC dialects may have to modifythe code to suit.The first test program is shown in Listing 1. Line 70 opens COM1(the first serial port) at Baud, o paritychecking, data bits, and stop bit. The timeouton CTS (clear to send) is set to 200 milliseconds, CD (carrierdetect) and DSR (data set ready) are disabled.
Another serial portcould be used in place of COM1 if required, by editing thisline.Line 80 accepts an input from the keyboard, the semicolon causesthe cursor to remain on the same line after ispressed. Line 90 terminates the program if no value is entered.Line 110 converts the entered data from a two character string to asingle byte and sends it down the serial port. Note that in BASICAHex numbers are indicated by preceding them with '&h', hencethe value of '&hFF' is 255.Lines 120 to 170 responsible for waiting up to 0.1 seconds fordata to be sent back up the serial port and displaying it. TIMER isa BASICA variable which contains the number of seconds sincemidnight to 2 decimal places (updated 18.2 times per second), thisis used in lines 120 and 130 to control the timeout. EOF(1) willhave a value of 0 if data is present, otherwise it will be 1. Line140 prints '.'
if a timeout has occurred, otherwise lines 150 to170 read the value, convert it from a single byte to a twocharacter string (using the HEX$ function) and print it. Line 180loops back round for another go!The second test program, shown in Listing 2, is used to test theaddress counter system. This clears the counters and thenrepeatedly increments them, by sending the appropriate codes. Theoperation should be evident, given the information above.The main control program is shown in Listing 3. This software isabout the minimum required to make sensible use of the programmer.It is written in a manner which should make the functioningrelatively easy to understand, and is not intended to be an exampleof good programming!The subroutines at lines 7000 to 7060, and 8000 to 8020 fetch abyte from the serial port and send a byte to the serial portrespectively. Their operation is as described in the Listing 1details above.
These subroutines are called frequently by theremainder of the program. Line 100 opens the serial communications as before. Lines 120 to300 attempt to establish communications with the programmer andtest whether or not the CTS connection is present and working.
M68hc08 Serial Programmer Schematics
Line120 sets the program pulse duration to 40 milliseconds, initiates aprogram pulse immediately followed by a send instruction. If CTS ispresent the send instruction will not be sent until the programpulse has finished so data will be received, otherwise no data willbe sent (see 'How it Works - Hardware'). The integer variablePAUSE% is set to 1 if there is no CTS line, causing the software toadd suitable delays itself - note that this will slow the operationof the software quite drastically.Lines 150 to 280 send values to the data latches and thenattempt to read them back - this is to establish that communicationis reliable.Lines 310 to 780 request information from the user regarding theEPROM type and programming requirements, whilst lines 790 to 820set up the programmer accordingly.Lines 1000 to 1230 form the main menu. Note that CHR$(27) givesthe value of the Escape key.The Read, Program and Verify sections use ASCII-HEX data filesin the programmers own format (conversion programs to and fromIntel-HEX are given later). The format is easy to produce and editmanually.The first line is the name of the EPROM type - '2716', '2732'etc. The remaining lines each start with the address in Hex (4digits), followed by four spaces, followed by 16 bytes in Hex (2digits) each separated by one space.
The addresses must besequential, starting at 0000.It should also be noted that this format is not particularlyefficient with disk space - the file for a 27512 will take up about250K. A file compression utility, such as PKZIP or LHARC, willdramatically reduce the size for storage if disk space is aproblem.With the information that has gone before, the operation of theremaining sections of the software should be fairly apparent.The section from 2000 to 2300 reads the contents of the EPROM toa file. Lines 2100 and 2110 give a quarter second delay to allowthe power supply rails to come up.The section from 3000 to 3390 programs the EPROM from thecontents of a file. Lines 3270 to 3290 add a delay (100milliseconds) to allow for the programming pulse if the CTS line isnot present, this will occur whether the programming pulse is 1 or40 milliseconds. This delay may be optimised but it would be betterto get CTS working in the first place.The section from 4000 to 4330 verifies (or compares) thecontents of the EPROM with a file, whilst the section from 5000 to5240 checks the device is blank (all locations contain 'FF'). Thesection from 6000 to 6220 allow the programming voltages to bechecked.The programs given in Listing 4 and Listing 5 convert the EPROMprogrammer data files to and from standard Intel-HEX data filesrespectively.
This is not the place for an explanation of theIntel-HEX file format, so please just accept that the programswork! Details of Intel-HEX and other standard file formats are onthe disk available from the author, together with variousconversion programs etc. In UseThe control software is shown in Listing 3 and is suitable for anIBM PC or compatible machine running BASICA, G.W.BASIC or QBASIC.This software is about the minimum required to make sensible use ofthe programmer. Section.If BASICA or G.W.BASIC is being used, the program will runfairly slowly. This is a limitation of interpreted BASIC.
QBASICsupplied with MS-DOS 5 is a much more advanced product and a gooddeal better in this respect.Additional (faster) software is supplied on the disk availablefrom the author (downloadable from this website).An EPROM must not be inserted or removed if the 'Program' or'Read' LED is lit, or if the programmer is configured for adifferent type of device. 24 pin EPROM's must be fitted in thelower pins (3-26) of the socket. In all cases pin 1 is upwards.Failure to observe the above may result in damage to the EPROM or(less likely) the programmer.The programmer should be switched on and connected to COM1(RS232 serial port 1) on the computer. Start the software and the'Program' LED will light. Once successful communication has beenestablished the program will request information about the type ofEPROM and the programming method required. See the table below orconsult the manufacturers data book.
EPROMProgrammingSupplyProgrammingType NumberVoltageVoltagePulse Length2716 & 27C1625V5V40mS2732 & 27C3221V5V40mS276421V5V1mS27C64 & 2764A12.5V5V1mS2712821V5V1mS27C128 & 27128A12.5V5V1mS27256 & 27C25612.5V6V1mS27512 & 27C51212.5V6V1mSSome 2764 and 27128 types require a complex arrangement ofprogramming pulses however a single 1mS pulse will usually suffice.If in doubt or if problems are experienced use 40mS. Although some2716 and 2732 devices will program successfully with a 1mSprogramming pulse, this is not recommended for final EPROM's, butmay prove useful when testing software etc.The use of the 'A' suffix on 12.5V 2764 and 27128 types appearsto be less than standard, it is suggested that all 2764's and27128's should be tried on 12.5V first, since 21V will destroy a12.5V device.Once these selections have been made the 'Program' LED willextinguish and the main menu will appear.' Read' (menu option 1) reads the contents of an EPROM to a file.Note that the file format used is non-standard, however programs toconvert to and from the Intel-HEX standard are given in Listings 4and 5. The advantage of the file format is that it is easy togenerate and edit manually.' Program' (option 2) programs the EPROM from a file. The EPROMis not blank checked before programming or verified afterwards,these operations should be done from the main menu individually ifrequired.'
Verify' (option 3) compares the contents of the EPROM with afile, and 'Blank Check' (option 4) does as it's name suggests! Boththese options report the number of locations that failed.' Change Configuration' (option 5) re-starts the software so theEPROM type and programming method can be changed.' Adjust Voltages' (option 6) allows the programming voltages tobe checked and adjusted if required.Happy programming!
On this page.The BootloaderThe behaviour described above happens thanks to a special piece of code that is executed at every reset of the microcontroller and that looks for a sketch to be uploaded from the serial/USB port using a specific protocol and speed. If no connection is detected, the execution is passed to the code of your sketch.This little (usually 512 bytes) piece of code is called the “Bootloader” and it is in an area of the memory of the microcontroller – at the end of the address space - that can’t be reprogrammed as a regular sketch and had been designed for such purpose. The programming process uses VCC, GND and four data pins. The Arduino MEGA above is programming an Arduino UNO connecting D51-D11, D50-D12, D52-D13, GND-GND, 5V-5V and D10 to RESET.
This type of board needs a 10µF electrolytic capacitor connected to RESET and GND with the positive (long leg) connected to RESET. The capacitor has to be placed after the programmer board has been loaded with the ISP sketch.The 10µF electrolytic capacitor connected to RESET and GND of the programming board is needed only for the boards that have an interface between the microcontroller and the computer's USB, like Mega, Uno, Mini, Nano. Boards like Leonardo, Esplora and Micro, with the USB directly managed by the microcontroller, don't need the capacitor.About voltagesThe Arduino family of boards includes 5V and 3.3V devices. When using an Arduino that is not 5V tolerant (Due, Zero.) as the programmer, make sure to not expose any of the programmer's pins to 5V.
A simple way to accomplish this is to power the complete system (programmer and target) at 3V3. In the above picture you see the wiring between a MKR1000 and a UNO. As described above, everything runs on 3.3V, taken from VCC and GND of the MKR1000 and sent to 5V and GND of the UNO. The same connection could be made to the ICSP of the UNO following the pinout explained in the page.
We have used the same colors for the wires as in the other pictures to help you switch from the 'old wiring' to the ICSP connector with ease. Please note that the MKR family of boards share the same pinout, therefore you can use any MKR board as ISP programmer. If you use a MKR board as ISP programmer, remember to change the line 73 of the ArduinoISP defining the actual pin used on the MKR board to Reset the target (6 in the picture above).Note: Please do not connect to USB or power supply the boards while you set up the connections and wires. We also suggest that you first program the Arduino used as ISP programmer before you proceed with the wiring to the target board.Load the sketchThe Arduino that you will use as programmer needs a specific sketch. You find it under Examples 11. ArduinoISP ArduinoISP. To upload the sketch to your Arduino board – the one that you will use as the programmer – you need to select board type and port, then you can proceed as usual.Program the bootloaderIf all the wires are set, you need to switch to the board type you want to program with the bootloader.
This step is mandatory to select the proper bootloader code and the fuses configurations. The programming procedure checks the signature of the microcontroller before any writing action is taken, but many boards share the same microcontroller and each board has its own bootloader. The port remains the one of the ArduinoISP.Choose “Burn bootloader” under tools and wait for the confirmation message in the lower part of the Arduino Software (IDE) interface. If you connected the LEDs you may follow the process visually. The Serial Programming ModeThe programming process manages the three SPI lines (MISO, MOSI and SCK) according to the standard SPI programming protocol, the same used to read and write SD memory cards. The only difference with memory cards is the lack of a CS (Chip select) pin. On our AVR microcontrollers we use the RESET pin that halts the execution of any sketch or bootloader and puts the microcontroller in a specific state where it listens to the commands arriving from the SPI interface.
The very first command that the protocol requires is the one that enters the microcontroller in the Serial Programming Mode.Once this specific mode is active, we can write and read all the microcontroller programmable areas: Flash, EEPROM and Fuses. At the end of the Flash memory, we have the bootloader code area, as highlighted in the image at the beginning of this article. The 'Burn Bootloader' procedure also sets properly the fuses of the microcontroller according to the design of the board. This is one of the reasons why you have to burn the bootloader selecting your exact board model in the list.Technical aspects of programmingThe open source software tool used to program the microcontroller is.