Application Portability For 32-Bit Microcontrollers - Reality or Myth?
Application Portability For 32-Bit Microcontrollers - Reality or Myth?
Application Portability For 32-Bit Microcontrollers - Reality or Myth?
Author: Erlendur Kristjansson Microchip Technology Inc. different parts of the microcontroller. Each silicon vendor will deliver a unique library, as their microcontroller will have different peripherals and features, which differentiates them from their competition. Let us look at the different parts of the microcontroller that comprise this differentiation from vendor to vendor.
INTRODUCTION
In November of 2008, ARM announced the availability of the Cortex Microcontroller Software Interface Standard (CMSIS). They claim that this will reduce the cost of designing software when creating projects for new devices or migrating existing software between Cortex-M based microcontrollers from different silicon vendors. This sounds very good, but is it valid? This paper investigates these claims to determine just how valid they are. We will take a look at the components of a typical microcontroller and then see just what can or cannot be gained by adding an abstraction layer on top of the typical peripheral firmware libraries. According to ARM, CMSIS is a vendor-independent hardware abstraction layer for the Cortex-M processor series. The CMSIS enables consistent and simple software interfaces to the processor for silicon vendors and middleware providers, simplifying software re-use, reducing the learning curve for new microcontroller (MCU) developers and reducing the time to market for new devices The creation of the CMSIS enables silicon vendors to focus their resources on the differentiating peripheral features of their product, and eliminates the need to maintain their own individual and incompatible standards for programming a microcontroller.1 To put this in context, we need to look at how microcontrollers fit into a design. A microcontroller is a highly integrated system solution. Actually, you can call it a System-on-Chip (SoC). As with any SoC, the chips function is defined by the hardware peripherals that are integrated with the CPU core. Of course, the performance and architecture of the CPU core defines what kind of code can be executed on the chip; but the chip's interaction with other parts of the system happens through the peripherals. What makes microcontrollers unique SoCs is the flexibility of their peripherals. Because of this flexibility, microcontroller setup and control can be fairly complex. A number of registers need to be set before anything actually happens. To help the designer with this task, the silicon vendor supplies firmware libraries that simplify the code development. These libraries include all the necessary functions to setup all the registers and control all the
SYSTEM ARCHITECTURE
Each microcontroller manufacturer has its own way of implementing the overall system integration i.e., system buses, clock trees and memory even when the CPU core is the same. These implementations allow them to create advantages that make their microcontroller a better solution for a customer. Lets explore each of these system elements: The clock tree provides the heartbeat of the system, coordinating the timing of all of the other functions. The clock tree is designed to optimize the system for speed and economy of operation. The features and peripherals that are included on the chip, as well as the problems the chip is designed to solve, directly influence the structure of the clock tree. Therefore, the clock tree structure is unlikely to be the same between manufacturers. And, the clock tree registers need to be programmed with the right values before anything else will happen. The architecture of the system buses defines how all of the MCU functions are integrated. Some manufacturers will use one or more peripheral buses, depending on the peripherals they integrate. All of this will change what and how many registers need to be set, in order to utilize all the available functions. Even though all microcontrollers have both nonvolatile memory, like Flash, and volatile memory, like SRAM, the exact integration is different for each manufacturer. Some connect the Flash memory directly to the core and to a bus matrix, while others connect it to a system bus or bus matrix. RAM is sometimes located in two independent banks to allow for simultaneous access by the core and peripherals. These varied memory structures might affect how the code is written, and they often have a direct impact on the performance of an application when a designer is moving from one manufacturer to another.
DS61164A-page 1
FIRMWARE LIBRARIES
As mentioned previously, each MCU manufacturer will have its own peripheral firmware libraries to help customers implement their designs and quickly move to the prototyping stage. A firmware library consists of code that has been developed by the chip manufacturer to set up all the registers for the various aspects of the chip, such as clocks, buses and peripherals. Providing function calls to easily set up the various registers helps developers concentrate on entering the parameters required for their applications. The function takes care of writing these parameters to the appropriate memory locations. By using the functions from the firmware library, the developer will not have to learn all of the registers and their locations to get the chip up and running. This saves time that can be focused on more application-specific tasks, such as developing the appropriate algorithms for the application. 2.
Through a careful reading of this description, we can see that what CMSIS gives us is a common language with which to describe the different components of the MCU. Next, lets take a look at a sampling of some of the features included in the MCUs produced by two different Silicon Partners (MCU manufacturers who use ARM Cortex-M processor cores).
TABLE 1:
Feature Communication Peripherals ADC Timers Internal Clock Frequency Max RAM Max Vendor A 5 X USART 3 X SPI Bus USB 2.0 OTG FS 12-bit 1 Msps 16-bit 72 MHz 48 kB Vendor B 4 X USART 3 X SPI/SSP Bus USB OTG 12-bit 200 ksps 32-bit 100 MHz 64 kB
DS61164A-page 2
DS61164A-page 3
PHILOSOPHY
The final point is to think about the basic microcontroller philosophy. MCUs were developed to bring the programmability and flexibility to control everyday devices. This goal has been achieved by integrating a CPU, non-volatile memory and peripherals, both analog and digital. By eliminating the higher-level functions that make computers so generic, microcontrollers can make the most of a very small amount of hardware. Firmware libraries dedicated to the particular peripheral structure of an MCU dramatically reduce the time and effort required to develop an application. As mentioned earlier, the addition of an abstraction layer to these libraries will help improve the development process and make it easier to reuse the code across multiple projects, but at a cost. There is both a code size and performance penalty when using an abstraction layer. Adding in an abstraction layer moves the microcontroller closer to being a computer. It is, in some ways, contrary to the special qualities that form the underlying philosophy of microcontrollers. In fact, it adds a complication to the development process by requiring that the application adhere to the specific language requirements of CMSIS, and it does not guarantee code compatibility.
REFERENCES
1
www.arm.com/products/processors/cortex-m/cortexmicrocontroller-software-interface-standard.php http://www.onarm.com/download/download395.asp
DS61164A-page 4
Note the following details of the code protection feature on Microchip devices: Microchip products meet the specification contained in their particular Microchip Data Sheet. Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions. There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchips Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property. Microchip is willing to work with the customer who is concerned about the integrity of their code. Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyers risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.
Trademarks The Microchip name and logo, the Microchip logo, dsPIC, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PIC32 logo, rfPIC and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. Analog-for-the-Digital Age, Application Maestro, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC, UniWinDriver, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. 2010, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper.
ISBN: 978-1-60932-622-7
Microchip received ISO/TS-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Companys quality system processes and procedures are for its PIC MCUs and dsPIC DSCs, KEELOQ code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchips quality system for the design and manufacture of development systems is ISO 9001:2000 certified.
DS61164A-page 5
ASIA/PACIFIC
Asia Pacific Office Suites 3707-14, 37th Floor Tower 6, The Gateway Harbour City, Kowloon Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 Australia - Sydney Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 China - Beijing Tel: 86-10-8528-2100 Fax: 86-10-8528-2104 China - Chengdu Tel: 86-28-8665-5511 Fax: 86-28-8665-7889 China - Chongqing Tel: 86-23-8980-9588 Fax: 86-23-8980-9500 China - Hong Kong SAR Tel: 852-2401-1200 Fax: 852-2401-3431 China - Nanjing Tel: 86-25-8473-2460 Fax: 86-25-8473-2470 China - Qingdao Tel: 86-532-8502-7355 Fax: 86-532-8502-7205 China - Shanghai Tel: 86-21-5407-5533 Fax: 86-21-5407-5066 China - Shenyang Tel: 86-24-2334-2829 Fax: 86-24-2334-2393 China - Shenzhen Tel: 86-755-8203-2660 Fax: 86-755-8203-1760 China - Wuhan Tel: 86-27-5980-5300 Fax: 86-27-5980-5118 China - Xian Tel: 86-29-8833-7252 Fax: 86-29-8833-7256 China - Xiamen Tel: 86-592-2388138 Fax: 86-592-2388130 China - Zhuhai Tel: 86-756-3210040 Fax: 86-756-3210049
ASIA/PACIFIC
India - Bangalore Tel: 91-80-3090-4444 Fax: 91-80-3090-4123 India - New Delhi Tel: 91-11-4160-8631 Fax: 91-11-4160-8632 India - Pune Tel: 91-20-2566-1512 Fax: 91-20-2566-1513 Japan - Yokohama Tel: 81-45-471- 6166 Fax: 81-45-471-6122 Korea - Daegu Tel: 82-53-744-4301 Fax: 82-53-744-4302 Korea - Seoul Tel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934 Malaysia - Kuala Lumpur Tel: 60-3-6201-9857 Fax: 60-3-6201-9859 Malaysia - Penang Tel: 60-4-227-8870 Fax: 60-4-227-4068 Philippines - Manila Tel: 63-2-634-9065 Fax: 63-2-634-9069 Singapore Tel: 65-6334-8870 Fax: 65-6334-8850 Taiwan - Hsin Chu Tel: 886-3-6578-300 Fax: 886-3-6578-370 Taiwan - Kaohsiung Tel: 886-7-213-7830 Fax: 886-7-330-9305 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350
EUROPE
Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 France - Paris Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Germany - Munich Tel: 49-89-627-144-0 Fax: 49-89-627-144-44 Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781 Netherlands - Drunen Tel: 31-416-690399 Fax: 31-416-690340 Spain - Madrid Tel: 34-91-708-08-90 Fax: 34-91-708-08-91 UK - Wokingham Tel: 44-118-921-5869 Fax: 44-118-921-5820
08/04/10
DS61164A-page 6