You are here

PSoC 3 Code Optimization | Cypress Semiconductor

PSoC 3 Code Optimization

Are you running out of 8051 code space in your PSoC 3, even after applying all of the Keil C51 compiler's optimizations? If you're using PSoC Creator's default mode, you're probably not taking advantage of many features of the 8051 architecture, which can greatly increase your code efficiency.
 
One common misconception when programming the 8051 is that the only way to get optimal code is to use 8051 assembler. This is not true, mainly because of the high performance capabilities of the Keil C51 compiler. Most if not all PSoC 3 8051 code can be written in C, and it can be made to be small, fast, and efficient. The cost is that you must use Keil-specific keywords, and C code containing these keywords may not be easily portable to other processors such as the Cortex-M3 in PSoC 5. However, PSoC Creator offers equivalent macros that make porting easier.
 
In any case, by using these keywords or macros, and with knowledge of some code architecture issues, you can make your 8051 code faster and smaller, and avoid using the PSoC 3 8051 in its slowest and least efficient mode.
 
The 8051 core is a 256-byte address space that contains 256 bytes of SRAM plus a large set of registers called Special Function Registers (SFRs). A lot of functionality is packed into this “internal space” and the 8051 is most efficient when it works in this space.
 
 
The Keil C compiler defines three memory models—small, compact, and large. The default model for PSoC Creator is large (to maintain compatibility with PSoC 5), but that default can be overridden for individual variables, functions, and even entire modules. The following code illustrates how this works.
 
 
 
 
The keywords ‘data’, ‘idata’, and 'pdata' are used to designate other models besides the (default) large model. In the above code, you can see that successively larger models require more flash bytes and more CPU cycles. So one of the most important methods to reduce code size if to place your most often-used variables in one of the internal data spaces.
                                                                                                   
In addition to the above tip, AN60630 provides a wealth of information on how to further reduce your code size by using the 8051 to its fullest capability.
 
By Mark Ainsworth

Comments

jordanss123 jordanss123's picture

fake Yeezy boost 350 black pirate real vs fake buy 80% Off http://www.yeezy350find.com

 

tech.seoteam_2739571's picture

Thank you for sharing with us, its really nice post , You can also visit below link Seo services in texas

tech experts's picture

Its really amazing article , Thank you for sharing with us netgear mywifiext.net not working

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.