====================================================================
============================ BitBangISP ============================
====================================================================
An ultra-simple bit of hardware to program the flash memory
in AT89S51/52/2051/4051. Now you can program the firmware for
an ISP programmer built with one of these microcontrollers,
without needing an ISP programmer! Or you could just use this
and forget about a "better" ISP programmer.
Written for all you hobbyists out there. Enjoy!
A schematic for the hardware should have been included,
if it is missing, contact me at the below email address.
--------------------------------------------------------------------
Copyright (C) 2020 Allen Fairfield
JoeElectronics43@outlook.com
Released under the GNU General Public License 3.0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------
If you compile this on Lazarus, first install the LazSerial component.
--------------------------------------------------------------------
If you are running this on Linux, be sure to add your user name to
the "dialout" group. I am not familiar with the various BSD
distributions or Mac/OS X, but this, or something similar might also
be needed.
--------------------------------------------------------------------
I'm using the "handshaking lines" for the serial port, but not TxD
or RxD. There are only two "output" lines, which I use for SCK and
MOSI, and in "input" line monitors MISO. There isn't a third "output"
to use for RST, so I use a momentary pushbutton switch for that. The
RST line is pulled high with a resistor, and pressing then releasing
the pushbutton brings RST low then high again. Luckily, that's enough
to bring the target microcontroller into programming mode. The app
will tell you when to press and release the pushbutton, so it can
then try to issue the Programming Enable commands via ISP. Then it
erases the program memory and writes the new code to it.
Before any of this happens, you must first open a HEX file that
you (or someone else) created. I use Asem-51, but anything that
creates a HEX file will do.
This programmer has no firmware, it is controlled by the app
written for it. A MAX232 is shown in the schematic, but I used a
MAX202 so I could use .1uf capacitors rather than 1uf electrolytics.
Both chips have the same pin-out, so you can use either. This
programmer will likely be slow, but it works, and is good for
programming the firmware for a programmer that is built with a
microcontroller. As long as that microcontroller is an AT89S51,
AT89S52, AT89S2051 or AT89S4051.
The application is written with Lazarus, so it's easy to port
to any operating system that it runs on.
Note: When the dialog pops up to select a serial port, ignore the
list of baud rates and other things. None of those are used here.
Just be sure to select the correct port. For Linux, using a USB
to serial converter cable, it will likely be /dev/ttyUSB0. For
Windows, if you see only one COM port, and you know for sure you
don't normally have a COM port, try that one. You might want to
go into system settings (I forget where, hardly use Windows these
days) to see what port your cable is listed as.
If you click the Cancel button in this dialog, a default
serial port will be selected. Unfortunately, there is no (known)
way to detect when the Cancel button is clicked, so I couldn't do
anything about this. Whatever port is selected in this case may not
be the one you want, so restart the app and try again. For the
Windows 10 build, I made the default COM1 (if I remember correctly).
For Linux, it may be /dev/ttyS0, it is on my PC, anyway. For Linux
you will want /dev/ttyUSB0 for the USB to serial cable.
I've compiled this app on Windows 10, to be sure it works with
that. If you use Windows 10, you can try the compiled EXE if you
don't want to install Lazarus just to compile it.