{"id":14434,"date":"2018-09-27T22:05:03","date_gmt":"2018-09-28T02:05:03","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=14434"},"modified":"2021-12-03T04:52:27","modified_gmt":"2021-12-03T09:52:27","slug":"exploring-stc-8051-microcontrollers","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/exploring-stc-8051-microcontrollers\/","title":{"rendered":"Exploring STC 8051 Microcontrollers"},"content":{"rendered":"<p style=\"text-align: justify\">8051 microcontrollers are the first-generation microcontrollers that sparked the modern embedded-system era and established the basic concepts for almost all microcontrollers. In the early 1980s, 8051 microcontrollers were first introduced by Intel. Later other manufacturers like Philips (NXP), Atmel (now Microchip), Silicon Labs, Maxim, etc took the 8051 architecture and introduced their variants of 8051s. Today there are hundreds of such companies which still manufactures this old school legendary micro. of them have even added more features like ADCs, communication peripherals like SPI and I2C, etc that were not originally incepted or integrated. There are even some manufacturers who produce micros under their naming convention\/branding while maintaining the basic architecture. Recently I covered an article about Nuvoton N76E003 <a href=\"http:\/\/embedded-lab.com\/blog\/category\/nuvoton\/\">here<\/a>. It is based on such ideas. <a href=\"https:\/\/www.stcmicro.com\">STC<\/a> (not to be confused with <em>STMicroelectronics<\/em>) is a Chinese semiconductor manufacturer that operates in the same way as Nuvoton. STC took the model of 8051 just like other manufacturers and upgraded it to new levels by implementing some vital upgrades, enhancements and additions. It also manufactures standard 8051s which are designed to fit in place of any other 8051s from any manufacturer. At present STC has several different variants of 8051s, ranging from standard 40 pin regular DIP 8051s to tiny 8-pin variants. Some are shown below.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC8051s.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14435\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC8051s-580x221.png\" alt=\"STC8051s\" width=\"580\" height=\"221\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC8051s-580x221.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC8051s.png 783w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\"><!--more--><\/p>\n<h1 style=\"margin-top: 0cm\">STC 8051s vs Other 8051s<\/h1>\n<p style=\"text-align: justify\">STC 8051s, as stated, offers additional hardware peripherals when compared to standard 8051s. There are some STC microcontrollers like STC89C52RC that are same as the standard ones while some others like STC8A8K64S4A12 are more robust with many advanced features. Some key differences between standard 8051s and STC micros are discussed below:<\/p>\n<ul>\n \t<li style=\"text-align: justify\"><em><span style=\"color: #339966\" data-darkreader-inline-color=\"\"><strong>Packages \/ Sizes<\/strong><\/span><\/em><br>\nSTC offers microcontrollers in various DIP and SMD IC packages. Thus, instead of using a 40-pin DIP package microcontroller to solve a problem that can be solved with an 8-pin SMD low cost microcontroller, we can avoid using a big microcontroller and thereby save valuable PCB space. Most STC 8051s are, by the way, 100% pin-compatible with other 8051s. This feature makes STC micros easy and viable replacements for devices that use standard 8051s.<\/li>\n<\/ul>\n<ul style=\"text-align: justify\">\n<li><span style=\"color: #339966\" data-darkreader-inline-color=\"\"><em><strong>Speed \/ Operating Frequency<\/strong><\/em><\/span><br>\nSTC microcontrollers are relatively faster than common 8051s as they can operate at higher clock frequencies. For example, AT89S52 has a maximum operating frequency of 33MHz while STC89C52RC can be clocked with an 80MHz source.<\/li>\n<\/ul>\n<ul style=\"text-align: justify\">\n<li><strong><em><span style=\"color: #339966\" data-darkreader-inline-color=\"\">Additional Hardware Peripherals<\/span><\/em><\/strong><br>\nSome STC microcontrollers have in-built ADC, EEPROM, watchdog timer, external interrupt pins and other peripherals. Some are even equipped with higher storage capacities. These are not available in typical 8051s.<\/li>\n<\/ul>\n<ul style=\"text-align: justify\">\n<li><span style=\"color: #339966\" data-darkreader-inline-color=\"\"><em><strong>Operating Voltage<\/strong><\/em><\/span><br>\nMost 8051 micros need 4.0 \u2013 5.5V DC supply voltage. Some can operate with 3.3V supplies too. Same goes for STC micros. However, there are some STC micros that are designed to operate at yet lower voltage levels. STC offers low power MCUs that operate between 2.0 \u2013 3.6V and general-purpose micros that can operate between 3.6 \u2013 5.5V. The operating voltage ranges and low power consumption figures of STC micros make them well-suited for battery and solar-powered devices.<\/li>\n<\/ul>\n<ul style=\"text-align: justify\">\n<li><span style=\"color: #339966\" data-darkreader-inline-color=\"\"><em><strong>Programming Interface<\/strong><\/em><\/span><br>\nMost 8051s require a parallel port programmer while some require serial port programmer or separate dedicated programmer hardware. STC micros on the other hand can be programmer with a serial port programmer and so there is no need to buy a dedicated programmer. A simple USB-TTL serial converter can be used to load codes into STC micros.<\/li>\n<\/ul>\n<ul style=\"text-align: justify\">\n<li><span style=\"color: #339966\" data-darkreader-inline-color=\"\"><strong><em>Other Minor Differences<\/em><\/strong><\/span><br>\nOther areas of differences include added\/reduced functionalities\/features. In some STC micros, there additional options for GPIOs, timers, etc while in some other devices these extras are not observed. For example, in STC89C52RC, there is 13-bit timer mode for timers 0 and 1 but this feature is absent in STC15L204EA. Likewise in STC15L204EA, there are many ways for setting up GPIOs which are not present in STC89C52RC.<\/li>\n<\/ul>\n<h1>Documentations and Websites<\/h1>\n<p style=\"text-align: justify\">STC microcontrollers are popular in China and Chinese-speaking countries. Owing to this fact, most of the documentation and even the websites are in Chinese. It is hard to get English documentations. Fortunately, we will not be needing anything else other than device datasheets which are luckily available both in Chinese and English.<\/p>\n<p style=\"text-align: justify\">Unlike other manufacturers who maintain one website dedicated to their products and themselves, STC maintains several websites. Most are in Chinese. This creates lot of confusion about STC. Some common STC websites are listed below:<\/p>\n<p style=\"text-align: justify\"><a href=\"http:\/\/www.stcmicro.com\">http:\/\/www.stcmicro.com<\/a><\/p>\n<p style=\"text-align: justify\"><a href=\"http:\/\/www.stcmcu.com\">http:\/\/www.stcmcu.com<\/a><\/p>\n<p style=\"text-align: justify\"><a href=\"http:\/\/www.stcisp.com\/\">http:\/\/www.stcisp.com<\/a><\/p>\n<h1 style=\"margin-top: 0cm\">Hardware Tools<\/h1>\n<p style=\"text-align: justify\">From AliExpress, DX, Alibaba and other similar websites\/stores, you can buy any STC development board of your choice. Alternatively, you can buy common STC chips and use them with your existing development board or setup a bread-board arrangement.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/stc.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14436\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/stc-580x408.jpg\" alt=\"stc\" width=\"580\" height=\"408\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/stc-580x408.jpg 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/stc.jpg 1024w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">One such board is shown above. These boards have lot of hardware devices like external 24 series EEPROM, I2C ADC-DAC, communication and display interfaces, etc already embedded and ready for go. Such boards are, thus easy to use and need less wiring. However, boards as such are relatively expensive and big than the one shown below:<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/nrf.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14437\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/nrf.jpg\" alt=\"nrf\" width=\"507\" height=\"361\"><\/a><\/p>\n<p style=\"text-align: justify\">This board is designed to bridge a serial interface between a host micro and a nRF24L01 2.4GHz wireless communication module. However, that doesn\u2019t restrict us from using the STC15F(L)204EA micro embedded in it. If you just want to give STC micros a shot with very little investment then this sort of board is all that you can ever expect.<\/p>\n<p style=\"text-align: justify\">In my tutorials, I\u2019ll be using both kinds of boards but the main focus will be towards STC15L204EA or similar slightly non-standard 8051s since they are not like playing with typical 8051s.<\/p>\n<p style=\"text-align: justify\">We will also need an USB-serial converter for uploading code.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/USB-Serial-Converter.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14438\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/USB-Serial-Converter-580x209.png\" alt=\"USB-Serial Converter\" width=\"580\" height=\"209\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/USB-Serial-Converter-580x209.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/USB-Serial-Converter.png 734w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Apart from these, some regularly used hardware items like LCDs, sensors, wires, etc will be needed. These can easily be found in any starter kit and most are available in any hobbyist\u2019s collection.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/new_starter_kit_waspmote_big.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14439\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/new_starter_kit_waspmote_big-580x438.jpg\" alt=\"new_starter_kit_waspmote_big\" width=\"580\" height=\"438\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/new_starter_kit_waspmote_big-580x438.jpg 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/new_starter_kit_waspmote_big.jpg 590w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<h1 style=\"margin-top: 0cm\">Software Tools<\/h1>\n<p style=\"text-align: justify\">Only two software tools will be needed. The first is Keil C51 compiler and second STC ISP tool.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14440\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-580x310.png\" alt=\"STC-ISP\" width=\"580\" height=\"310\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-580x310.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-1024x548.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP.png 1364w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">STC ISP tool can be downloaded from <a href=\"https:\/\/www.stcmicro.com\/rjxz.html\">here<\/a>. 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.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14441\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil.png\" alt=\"Keil\" width=\"445\" height=\"227\"><\/a><\/p>\n<p style=\"text-align: justify\">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. For example, STC89C52RC is similar to AT89S52. You can use codes for such interchangeably. However, this method won\u2019t work in cases where we have more hardware peripheral than an ordinary 8051 micro. STC15L204EA, for instance, can\u2019t be used like ordinary 8051 or like STC89\/90 series micros.<\/p>\n<h1 style=\"margin-top: 0cm\">Programming STC Microcontrollers<\/h1>\n<p style=\"text-align: justify\">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.<\/p>\n<p style=\"text-align: justify\">First run the STC-ISP tool.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-Icon.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14442\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-Icon.png\" alt=\"STC-ISP Icon\" width=\"98\" height=\"98\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-Icon.png 98w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-Icon-90x90.png 90w\" sizes=\"auto, (max-width: 98px) 100vw, 98px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">After clicking the STC-ISP tool icon, the application starts and the following window appears:<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Garbage.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14443\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Garbage.png\" alt=\"Garbage\" width=\"431\" height=\"407\"><\/a><\/p>\n<p style=\"text-align: justify\">Don\u2019t worry. It is not an error or garbage text window. It appears so if you don\u2019t have Chinese font database installed in your PC and so just click OK to continue. Recent versions of STC-ISP don\u2019t have this issue.<\/p>\n<p style=\"text-align: justify\">Once the application starts, navigate to <strong><em>Keil ICE Settings<\/em><\/strong> tab and locate the highlighted button as shown below:<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-ICE.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14444\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-ICE-580x309.png\" alt=\"Keil-ICE\" width=\"580\" height=\"309\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-ICE-580x309.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-ICE-1024x545.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-ICE.png 1364w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Now just navigate to Keil installation folder and hit OK as shown below:<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Folder.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14445\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Folder-580x326.png\" alt=\"Keil Folder\" width=\"580\" height=\"326\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Folder-580x326.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Folder-1024x576.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Folder.png 1366w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Selecting wrong folder will end up with an error and the database won\u2019t be installed.<\/p>\n<p style=\"text-align: justify\">If the database addition is a success, you\u2019ll get the following message:<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Add-Successful.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14446\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Add-Successful-580x340.png\" alt=\"Add Successful\" width=\"580\" height=\"340\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Add-Successful-580x340.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Add-Successful.png 798w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Now run Keil C51 compiler.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Icon.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14447\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Icon.png\" alt=\"Keil Icon\" width=\"99\" height=\"99\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Icon.png 99w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Icon-90x90.png 90w\" sizes=\"auto, (max-width: 99px) 100vw, 99px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Go to <strong><em>Project &gt;&gt; New <\/em><\/strong><strong><em>\u00b5Vision Project\u2026 <\/em><\/strong>as shown below:<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14448\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-1-580x309.png\" alt=\"Keil New Project 1\" width=\"580\" height=\"309\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-1-580x309.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-1-1024x546.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-1.png 1366w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Give your project a folder and a name as shown below:<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14449\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-2-580x310.png\" alt=\"Keil New Project 2\" width=\"580\" height=\"310\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-2-580x310.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-2-1024x547.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-New-Project-2.png 1366w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p>Select STC Database and appropriate chip or similar part number.\n<\/p><p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Chip-Selection.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14450\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Chip-Selection-580x310.png\" alt=\"Keil Chip Selection\" width=\"580\" height=\"310\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Chip-Selection-580x310.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Chip-Selection-1024x547.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Chip-Selection.png 1366w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Please note that your target chip may not be in the list. For example, the L-series chips are not enlisted in the database and so they are absent in the list. STC15L204, for example, is not shown in the list. You can use STC15F204EA instead of it as they are similar stuffs. The only difference is their power consumptions. You have to use such tricks when your target chip is not listed. Make sure that the model you selected matches with the target chip or else things may not work properly.<\/p>\n<p>After chip selection, add the startup assembler file to your project.\n<\/p><p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Startup-File.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14451\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Startup-File.png\" alt=\"Keil Startup File\" width=\"416\" height=\"153\"><\/a><\/p>\n<p style=\"text-align: justify\">By default, Keil doesn\u2019t add\/create any file and so you\u2019ll see that the project folder has no main source file. We\u2019ll have to create one main source file and add additional files if needed.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Main-File.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14452\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Main-File-580x310.png\" alt=\"Keil Main File\" width=\"580\" height=\"310\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Main-File-580x310.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Main-File-1024x547.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Main-File.png 1366w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">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.<\/p>\n<p>Again, we need to take the help of STC-ISP tool.<\/p>\n<p>In STC-ISP tool, locate the <strong><em>Header File<\/em><\/strong> tab and select appropriate MCU series.\n<\/p><p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Header-File.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14453\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Header-File-580x310.png\" alt=\"Header File\" width=\"580\" height=\"310\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Header-File-580x310.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Header-File-1024x548.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Header-File.png 1364w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Save or copy the file to your desired location.<\/p>\n<p style=\"text-align: justify\">In Keil, go to target options by right click the folder icon and set target options as shown in the following screenshots:<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14454\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-580x310.png\" alt=\"Keil Target Settings\" width=\"580\" height=\"310\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-580x310.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-1024x547.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings.png 1364w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14455\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-1-580x437.png\" alt=\"Keil Target Settings 1\" width=\"580\" height=\"437\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-1-580x437.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-1.png 631w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p>From this window select clock frequency and memory model.\n<\/p><p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14456\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-2-580x435.png\" alt=\"Keil Target Settings 2\" width=\"580\" height=\"435\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-2-580x435.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-2.png 630w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Select <strong><em>Create HEX File<\/em><\/strong> from this window as this file will be uploaded in the target chip.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14457\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-3-580x252.png\" alt=\"Keil Target Settings 3\" width=\"580\" height=\"252\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-3-580x252.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-3-1024x444.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-3.png 1279w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">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.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14458\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-4-580x437.png\" alt=\"Keil Target Settings 4\" width=\"580\" height=\"437\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-4-580x437.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Keil-Target-Settings-4.png 629w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p>Lastly disable<em> <strong>Warning Number 16<\/strong><\/em>. Now, we are good to code.\n<\/p><p style=\"text-align: justify\">I made a small Youtube video on all the above discussed processes. If you didn\u2019t understand some part or if you are confused at some point, you can watch the video <a href=\"https:\/\/youtu.be\/nHCjFw2TS4M\">here<\/a>.<\/p>\n<p><iframe loading=\"lazy\" title=\"How to use Keil C51 Compiler to Code STC 8051 Microcontrollers\" width=\"860\" height=\"484\" src=\"https:\/\/www.youtube.com\/embed\/nHCjFw2TS4M?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/p><p style=\"text-align: justify\">Now let us discuss about uploading codes to STC micros. The most advantageous part is the fact that we don\u2019t need to invest on a dedicated programmer as with other microcontrollers as a simple USB-serial converter will do the job. However, on first go things may look confusing.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-Steps.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14459\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-Steps-580x310.png\" alt=\"STC-ISP Steps\" width=\"580\" height=\"310\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-Steps-580x310.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-Steps-1024x547.png 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/STC-ISP-Steps.png 1362w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Shown above is the STC-ISP tool\u2019s screenshot with numbers. We have to follow them one-by-one and in incremental order. 1 denotes that we must select the right COM port and part number. You can use <strong><em>Windows Device Manager<\/em><\/strong> to find out which COM port is being used for uploading code. Step 2 is to select the target HEX code file. Optionally in step 3, we can set some additional internal MCU parameters. When everything has been set properly, we can hit the <strong><em>Download Program<\/em><\/strong> button shown in step 4. If the target microcontroller or board is already powered then the code won\u2019t be uploaded. This is the confusing part because it should have been the other way.<\/p>\n<p style=\"text-align: justify\">Notice the red arrow in the schematic below. The code is not uploaded by holding and releasing the reset button for some time or by pulling high or low some special pin or by some other means. We need to create a handshake between the PC and the target MCU and this is done when the MCU is powered off and then powered on, i.e. when the micro is powered up.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/ISP-Circuit.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14460\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/ISP-Circuit.png\" alt=\"ISP Circuit\" width=\"565\" height=\"571\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/ISP-Circuit.png 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/ISP-Circuit-90x90.png 90w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">This is why the red arrow highlights the power switch in the schematic. Though the schematic shows a MAX232-based converter, we can use a USB-serial converter instead.<\/p>\n<p style=\"text-align: justify\">All of these steps are demoed in <a href=\"https:\/\/youtu.be\/PcvktG9sc9Q\">this video<\/a>. Note that no external USB-serial converter\/cable can be seen in the video as it is embedded in the board. The following schematic and photo will make this fact clearer. This is why most STC development boards come with such arrangement and without any programmer.<\/p>\n<p><iframe loading=\"lazy\" title=\"How to Load a Hex File in a STC Microcontroller\" width=\"860\" height=\"484\" src=\"https:\/\/www.youtube.com\/embed\/PcvktG9sc9Q?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/p><p style=\"text-align: center\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Cut-Away-Schematic.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14462\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Cut-Away-Schematic-580x309.png\" alt=\"Cut Away Schematic\" width=\"580\" height=\"309\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Cut-Away-Schematic-580x309.png 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/Cut-Away-Schematic.png 841w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a> <a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/board.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-14461\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/board-580x341.jpg\" alt=\"board\" width=\"580\" height=\"341\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/board-580x341.jpg 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/board-1024x603.jpg 1024w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2018\/09\/board.jpg 1369w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n\n\n<p class=\"wp-block-paragraph\">The continuation of this post can be found <a href=\"https:\/\/embedded-lab.com\/blog\/exploring-stc-8051-microcontrollers-coding\/\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>8051 microcontrollers are the first-generation microcontrollers that sparked the modern embedded-system era and established the basic concepts for almost all microcontrollers. In the early 1980s, 8051 microcontrollers were first introduced by Intel. Later other manufacturers like Philips (NXP), Atmel (now Microchip), Silicon Labs, Maxim, etc took the 8051 architecture and introduced their variants of 8051s. Today there are hundreds of such companies which still manufactures this old school legendary micro. of them have even added more features like ADCs, communication peripherals like SPI and I2C, etc that were not originally incepted or integrated. There are even some manufacturers who produce<\/p>\n","protected":false},"author":5,"featured_media":14435,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1734],"tags":[1646,1722,1733,1732],"class_list":["post-14434","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-stc8051","tag-8-bit-microcontroller","tag-1722","tag-stc","tag-stc-micrcontroller"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/14434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=14434"}],"version-history":[{"count":6,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/14434\/revisions"}],"predecessor-version":[{"id":15385,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/14434\/revisions\/15385"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/14435"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=14434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=14434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=14434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}