THE EARLY YEARS (II)
Towards the end of 1993 it occurred to me that given the popularity of another microcontroller in electronics magazines (mainly those "borrowed" issues of Elektor from a classmate's dad), and the fact that I encountered this other microcontroller a year earlier in a pay-tv decoder box*, I would likely have a better chance at building my first microcontroller project by working with the legendary Intel 8031. Around this time I was trying hard to figure out HD44780 based LCD character displays and I already knew that I would be better off attempting to control it with software than trying to "work" the display by hand.
The Journey to coding (and setting the stage for the rest of my life)
Somewhere in 1994 I managed to get a photocopy of the MCS-51 instruction set. I remember borrowing the book from another classmate's dad, going to the copy shop and spending, literally, all the money I had to my name, to have the book photocopied. I also copied the instruction set to A-5 and made a little booklet, which I used until at least 1999 by which time it was tattered, torn, and well used.
When I made those photocopies, again bear in mind I had no computer, nothing! All I had was the determination to get this working.
In October 1994 I was finished with college for the time being, and I earned some money somewhere. For the sum of ZAR 23, I bought two INTEL 8031 micros from RS Electronics** in Johannesburg. These two chips were my gateway into the world of coding, all those years ago.
The Journey to coding (and setting the stage for the rest of my life)
Somewhere in 1994 I managed to get a photocopy of the MCS-51 instruction set. I remember borrowing the book from another classmate's dad, going to the copy shop and spending, literally, all the money I had to my name, to have the book photocopied. I also copied the instruction set to A-5 and made a little booklet, which I used until at least 1999 by which time it was tattered, torn, and well used.
When I made those photocopies, again bear in mind I had no computer, nothing! All I had was the determination to get this working.
In October 1994 I was finished with college for the time being, and I earned some money somewhere. For the sum of ZAR 23, I bought two INTEL 8031 micros from RS Electronics** in Johannesburg. These two chips were my gateway into the world of coding, all those years ago.
The actual integrated circuits as purchased in October 1994. The unit in the foreground still works, the unit in the background has a blown I/O port pin
So with the purchase of the two ICs I was in a position to breadboard a complete 8051 based system which I did. The next problem was getting a program developed and programmed into an EPROM***. I had a 2764 8k x 8 EPROM salvaged from a scrapped card terminal, so I had that at least.
POWERING THROUGH TOUGH TIMES
Now I mentioned I didn't have a computer. Well my brother did and it was not what one would call a personal computer that could run the programs that were so readily available out there. So during October 1994 I constructed an EPROM programmer on veroboard with the necessary logic to interface to the one computer we did have- a Sinclair ZX Spectrum. My brother wrote the EPROM programmer software in BASIC with some assembler, and I built the electronics which we plugged into the back of the computer.
POWERING THROUGH TOUGH TIMES
Now I mentioned I didn't have a computer. Well my brother did and it was not what one would call a personal computer that could run the programs that were so readily available out there. So during October 1994 I constructed an EPROM programmer on veroboard with the necessary logic to interface to the one computer we did have- a Sinclair ZX Spectrum. My brother wrote the EPROM programmer software in BASIC with some assembler, and I built the electronics which we plugged into the back of the computer.
HOW THE HECK DID I MANAGE THAT?
So the obvious question is how did I manage to program (and erase) the 2764 EPROM.
Well luckily the info on the 2764 was in that legendary MAPLIN catalogue I mentioned before, and I was able to program bytes to the device after figuring it out from the datasheet. I did breadboard it first to test the concept of course.
How did I erase the EPROM? Well, that was also a trick, based on my discovery that putting the EPROM outside in a tray of tap water and letting it sit in the sun, pretty much erased the entire device by the end of the day. Slow but it worked!
CODING WITH PEN AND PAPER
I had no access to an IBM PC type computer, and also no 8051 assembler. There was no such program for the ZX Spectrum anyway and besides where would we get such a thing? No internet!
This is where one of my magazine borrowing expeditions came in handy. In the January 1994 issue of ELEKTOR ELECTRONICS I found an article about an 8051 simulator, and in that article was a small piece of code that flashed an LED. Even then, with no programming experience in embedded or otherwise, by pure intuition I knew that a flashing LED was the functional equivalent of "Hello, world".
So the obvious question is how did I manage to program (and erase) the 2764 EPROM.
Well luckily the info on the 2764 was in that legendary MAPLIN catalogue I mentioned before, and I was able to program bytes to the device after figuring it out from the datasheet. I did breadboard it first to test the concept of course.
How did I erase the EPROM? Well, that was also a trick, based on my discovery that putting the EPROM outside in a tray of tap water and letting it sit in the sun, pretty much erased the entire device by the end of the day. Slow but it worked!
CODING WITH PEN AND PAPER
I had no access to an IBM PC type computer, and also no 8051 assembler. There was no such program for the ZX Spectrum anyway and besides where would we get such a thing? No internet!
This is where one of my magazine borrowing expeditions came in handy. In the January 1994 issue of ELEKTOR ELECTRONICS I found an article about an 8051 simulator, and in that article was a small piece of code that flashed an LED. Even then, with no programming experience in embedded or otherwise, by pure intuition I knew that a flashing LED was the functional equivalent of "Hello, world".
The magazine issue that changed everything - Elektor Electronics January 1994
So I was pretty broke from spending all I had on two 8051 ICs, I couldn't afford to photocopy stuff, so I did the next best thing. I copied, by hand, the code in Fig. 1. to my notebook...
A real Kintaro Oe moment - I copied all of that to my notebook
I spent a lot of time, about two weeks working through the code listing in the article. As a result, to this day I remember the op codes of that program from memory and can recite them here:
74 FF 14 FD 00 70 FB 11 0B 80 F5 B2 90 22
I no longer have the notebook, but I remember clearly mapping them to the 8051's instructions and working out how the SJMP instruction worked (op code 0x80, 0xF5 is the destination address +127 or - 127 from the current address.
So, as I can still recall, 0xF5:
0xFF - 0xF5 = 0x0A, and because the 8th bit is set, the displacement goes backwards.
Instruction 0x80 [SJMP] resides on address 0x0A, therefore:
0x0A - 0x0A = 0x00 which in higher level assembly language would be written as
Start:
...
...
...
SJMP Start;
When I was ready, I used the ZX Spectrum with my ramshackle EPROM programmer and programmed them to the EPROM.
IT WORKED
Can you imagine how I felt when I plugged that EPROM into the breadboard, connected power and the LED on P1.0 of the microcontroller began to flash? Feelings of excitement, buzz, all of that. I remember taking that breadboard and walking all the way from my house to my classmate's dad to show him. I had to show someone, also again, no engineer to talk to, nobody to mentor me.
WHAT HAPPENED NEXT
From this point on, I began to develop software, with pen and paper, working out the op-codes and operands to implement a program to build my first project. In November 1994 I managed to write a program that pretty much did what the 68HC05 was doing, a car alarm. A bit of trial and error did take place as I would have to figure out how to read from the I/O ports, and I remember the bit test instructions being a bit confusing but I prevailed. Early in December I began to lay out a PC board for the car alarm, using the traditional method of making a film with dry transfers. I had the PC board made at the electronics shop that was about to hire me anyway, for around ZAR30, and I assembled it and it worked.
In January 1995 I began working at a local electronics company that had a retail shop selling components. This job and the adjustment thereto didn't leave me as much time as I was used to so I didn't do much development. Things happened fast though. By April I convinced my dad we needed a computer urgently and he gave in, we had a brand new 486 with Windows 3.11 in our home by Easter Weekend 1995. With that, came stuff from work, firstly a copy of Tango PCB II (from that point it was game over with the dry transfers as I could now do PCB layouts and take the files to work on a floppy diskette) and then I was given a copy of the INTEL MCS-51 MACRO ASSEMBLER.
But, as this was going on, my newly gained programming expertise was being pulled in another direction. My employer wanted me to work with PIC microcontrollers urgently, and even paid for me to go on a training course. And because I had a computer at home, I was given a programmer to program the device.
74 FF 14 FD 00 70 FB 11 0B 80 F5 B2 90 22
I no longer have the notebook, but I remember clearly mapping them to the 8051's instructions and working out how the SJMP instruction worked (op code 0x80, 0xF5 is the destination address +127 or - 127 from the current address.
So, as I can still recall, 0xF5:
0xFF - 0xF5 = 0x0A, and because the 8th bit is set, the displacement goes backwards.
Instruction 0x80 [SJMP] resides on address 0x0A, therefore:
0x0A - 0x0A = 0x00 which in higher level assembly language would be written as
Start:
...
...
...
SJMP Start;
When I was ready, I used the ZX Spectrum with my ramshackle EPROM programmer and programmed them to the EPROM.
IT WORKED
Can you imagine how I felt when I plugged that EPROM into the breadboard, connected power and the LED on P1.0 of the microcontroller began to flash? Feelings of excitement, buzz, all of that. I remember taking that breadboard and walking all the way from my house to my classmate's dad to show him. I had to show someone, also again, no engineer to talk to, nobody to mentor me.
WHAT HAPPENED NEXT
From this point on, I began to develop software, with pen and paper, working out the op-codes and operands to implement a program to build my first project. In November 1994 I managed to write a program that pretty much did what the 68HC05 was doing, a car alarm. A bit of trial and error did take place as I would have to figure out how to read from the I/O ports, and I remember the bit test instructions being a bit confusing but I prevailed. Early in December I began to lay out a PC board for the car alarm, using the traditional method of making a film with dry transfers. I had the PC board made at the electronics shop that was about to hire me anyway, for around ZAR30, and I assembled it and it worked.
In January 1995 I began working at a local electronics company that had a retail shop selling components. This job and the adjustment thereto didn't leave me as much time as I was used to so I didn't do much development. Things happened fast though. By April I convinced my dad we needed a computer urgently and he gave in, we had a brand new 486 with Windows 3.11 in our home by Easter Weekend 1995. With that, came stuff from work, firstly a copy of Tango PCB II (from that point it was game over with the dry transfers as I could now do PCB layouts and take the files to work on a floppy diskette) and then I was given a copy of the INTEL MCS-51 MACRO ASSEMBLER.
But, as this was going on, my newly gained programming expertise was being pulled in another direction. My employer wanted me to work with PIC microcontrollers urgently, and even paid for me to go on a training course. And because I had a computer at home, I was given a programmer to program the device.
* M-NET DECODER, analogue pay-television set-top box, now completely obsolete and irrelevant.
** Not to be confused with the UK based RS Components PLC. RS Electronics was a high street electronic component retailer and esoteric hi-fi specialist during the 80s and 90s
*** EPROM was the dominant technology until FLASH memory became commonplace and rendered it obsolete.
** Not to be confused with the UK based RS Components PLC. RS Electronics was a high street electronic component retailer and esoteric hi-fi specialist during the 80s and 90s
*** EPROM was the dominant technology until FLASH memory became commonplace and rendered it obsolete.