STC Programming
STC Programming
Software Tools
Only two software tools will be needed. The first is Keil C51 compiler and
second STC ISP tool
STC ISP tool can be downloaded from here. This is one helluva tool that has
many useful features. It a programmer interface, a code generator, serial port
monitor, code bank and many other stuffs. It sure does make coding STC
micros lot easier than you can possibly imagine.
Keil C51 C compiler will be needed to code STC micros. At present, Keil is the
only C compiler that can be used reliably to code STC micros. STC
documentations speak of Keil mostly. If you want to use some other compiler
like IAR Embedded Workbench, MikroC for 8051, etc other than Keil, your
have to add the SFR definitions of your target STC micros and do other stuffs
to familiarize it with the STC micro target. Alternatively, you can use models
of other similar 8051 model.
Programming STC
Microcontrollers
By default, STC microcontroller database is absent in Keil. It is imperative
that this database is added to Keil when using it for STC micros for the very
first time. Though this database is not complete in the sense that not chips
are enlisted in it, it is still a must or else we will have to use unconventional
coding methods by using models of similar microcontrollers of different
manufacturers. Personally, I hate unconventional tactics because why use
such methods when we can add the database easily. We only have to add
this database once.
Once the application starts, navigate to Keil ICE Settings tab and locate the
highlighted button as shown below:
Now just navigate to Keil installation folder and hit OK as shown below:
Selecting wrong folder will end up with an error and the database won’t be
installed.
By default, Keil doesn’t add/create any file and so you’ll see that the project
folder has no main source file. We’ll have to create one main source file and
add additional files if needed.
Still we are not ready to start coding. This is because we have not yet added
SFR definition header file and other custom optional files.
In STC-ISP tool, locate the Header File tab and select appropriate MCU
series.
Save or copy the file to your desired location.
In Keil, go to target options by right click the folder icon and set target
options as shown in the following screenshots:
From this window select clock frequency and memory model.
Select Create HEX File from this window as this file will be uploaded in the
target chip.
This section above is highly important because here we have to show the
compiler the locations of the header or include files. Check the step
numbering carefully
Lastly disable Warning Number 16. Now, we are good to code.
I made a small Youtube video on all the above discussed processes. If you
didn’t understand some part or if you are confused at some point, you can
watch the video here.