The problem of many developers is that they cannot imagine, how to program the MCU using the higher language comparing to PC programming. There is also a question “Why to change my program tools, if the old ones are still well working?” We would like to answer this question in the following text.
The development from the application point of view
The complexity of the MCU applications from the automotive, GSM and other areas is expecting the usage of higher programming languages.
The advantages of the higher programming languages:
- Reduction of the development time and the development costs
- The source codes are more “readable”
- Longer-range project administration
- The multi-platform usage of the source codes
The MCU producers support this trend and they are implementing much more RAM and FLASH memory than before. Datasheets of the new MCUs directly state that the MCU is usable for the higher programming method.
Why to use the C language?
The C language was developed for the system low-level programming at the beginning. It was used for direct programming and control of any HW circuits. There are many operating systems written in C language and also quite a lot of user MCU applications. The C compilers are made for most of the MCUs.
C language advantages
- Easy source code portability
- Multi-platform programming
- Lucidity of the source codes of the program and global simplification of the developing process
- Quicker application development (standard libraries usage)
- Optimalization and validation tools
- The language is well known and supported by the MCU producers, quite a lot of SW producers available.
C language disadvantages
- Higher price of the high quality development tool
- Higher data and code memory requirements
- More difficult to learn
The C language implementations for the x51 family
The x51 microprocessors are still available and quite a lot of developers are using this type of MCU, so the producers are developing new clones, which can be used for programming in C. The basic property of the C language is that it mostly uses the stack. That was the problem why the C language was not so usable before, because of the small stack type memory is implemented in the x51 MCUs. It very depends on how well the C language producer implements the stack on the x51. The memory size of implemented RAM is going to be higher, so the stack implementation problem was solved by several C language producers. There are more problems when using the 8bit x51 MCUs:
- Access to internal and external peripherals
- Interrupt control
- Optimal usage of the limited instruction set
- Specific properties of the different memory blocks
- The multi ROM and RAM configuration support
- The high level of optimization for maximal code memory usage
- The memory bank switching
- The support of different 8051 clones .
One could easily find more than 20 C language compilers for the x51 family. How to chose the right and best one?
See the producer’s web pages as a step 1. Usually, you will be able to download a trial version of the compiler and try if it is suitable for your project.
These trial versions are usually limited for instance:
- By the source code size
- By the starting address of the code
- By the usage time limit
- There are only several libraries available
- By the available memory models
- By the supported x51 clones
- And so on.
The downloaded trial version is usually good for testing, studying and for beginners or amateurs. You might develop quite many interesting applications even with the trial version.
If you are looking for some GNU project open source C compiler, you should chose the SDCC. It seems that SDCC is the only one under the GNU project. It’s not a low-end compiler, the code optimization is somewhere in the middle. It’s very suitable for small and middle applications. If you are interested in large project developing, we should recommend you to use a commercial product with strictly defined support.
Author: Jan Rehak