Set up the development environment of the Linux system for the master node of the master node.
The first contact with single-chip microcomputer, naturally choose a simple 51 single-chip microcomputer. However, my operating system is Linux. It seems easy to get started with 51 in Windows. However, it is not easy to build 51 development environment on Linux.
Let's talk about how to set up the development environment of the STC89C52RC in Linux.
(1)
Select your preferred code editor. Vim, emacs, gedit, and so on.
(2)
Install the compiler. Select sdcc. Generally, you can install it directly from the package manager of the release version.
In Arch, for example:
$ Sudo pacman-S sdcc
If not, you need to download and compile it yourself.
A Brief Introduction to sdcc:
Assume that the current directory has a written source file main. c. Compile with the following simple method.
$ Sdcc main. c
Among the several generated files, main. ihx is a generated hexadecimal executable file. Then you can burn it into the microcontroller.
(3)
A download line is required to burn the generated executable program to the microcontroller. Generally, the download line of the USB to serial port is used. After plugging in, there is a device named ttyUSB * In/dev, which can be followed.
Otherwise, you may need to install a USB-to-serial driver.
Select the burning tool. Most of the files on the Internet are burned out using the tool stcisp. But after I try it, it is always stuck in the place where We are trying to connect your MCU.
At first I thought there was a problem with the download line. Later I found no. You can try. Note that the stcisp requires a binary file, so you need to convert main. ihx to a binary file.
An example of conversion:
$ Makebin <main. ihx> main. bin
You need to change the file name to your own file name. There are many other ways to search by yourself.
I tested a burning tool, stcflash. This is a python script. Therefore, you need to install the python environment. Python is installed in most Linux distributions. However, you need to install an additional runtime python-serial.
$ Sudo pacman-S python-serial
Put the downloaded stcflash. py in the source file directory. Next, we will start the installation.
First, close the board. Run
$ Sudo python./stcflash. py./main. ihx
Open the Development Board to download it. The successful result is as follows:
Connect to/dev/ttyUSB0 at baudrate 2400
Detecting target... done
Forsc: 11.996 MHz
Model: Maid (ver4.3C)
ROM: 8KB
Baudrate: 38400
Erasing target... done
Size of the binary: 218
Programming: #################### done
In addition, you can use stcflash to download binary files.
SDK: http://sdcc.sourceforge.net/snap.php#Linux
GSTCISP: http://osdn.jp/projects/sfnet_gstcisp/releases? Fulllist = 1
Stcflash: https://github.com/RainMark/stcflash.git
This article permanently updates the link address: