Global Sources
EE Times-India
Stay in touch with EE Times India
EE Times-India > Controls/MCUs

Compilation techniques for PIC32

Posted: 04 May 2009     Print Version  Bookmark and Share

Keywords:PIC32  microcontrollers  nonvolatile-memory 

The PIC32 is a major departurefrom Microchip�s bread-and-butteroffering of 8- and 16-bit microcontrollers,so developing codefor the PIC32 poses a new set ofchallenges. The highest nonvolatile-memory (NVM) density on8-/16-bit PIC MCUs is 128 kbytes,SRAM is limited to 4 kbytes or less,and 16 registers is the maximum.Midrange PICs have as few as oneor two registers and even smallermemory densities.

All 8-/16-bit PIC MCUs have banked memories that require assembly language or nonstandard C extensions to address efficiently, resulting in nonportable code. Thus, in spite of the common peripheral set and development environment shared by the PIC32 and its 8-/16-bit precursors, migrating nonstandard legacy code could pose serious complications.

In contrast to previous PICs, PIC32 devices have as much as 512 kbytes of flash, up to 32 kbytes of SRAM memory, and 32 general purpose registers. Also unlike 8-bit PICs, the PIC32 memory space is linear, so no complicated addressing schemes are required.

With fast DSP instructions for multiply and divide, a 256-byte instruction cache, 5-stage pipeline, direct memory access, and fast context switching, the PIC32 offers instruction throughput of 1.56 DMIPS (Dhrystone million instructions per second)/MHz—the highest of any microcontroller in its class. Its 80 MHz maximum clock provides PIC32 users with unparalleled throughput and flexibility. So, the question is how does an engineer develop code to take full advantage of the PIC32's horsepower?

One way to squeeze the maximum performance from a PIC32 is to choose a compilation method that exploits the benefits of the architecture while offering a seamless up/down migration path for legacy code. Basically, there are two approaches to compilation for the PIC32 architecture: conventional compilation that optimizes and generates object code independently for each individual program module and "omniscient" compilation that optimizes code based on a view of all program modules, across the entire program.

Conventional compilation
Conventional compilation technology (Figure 1) shadows the modular embedded software design process, in which programs are broken up into modules—partly to accommodate their increasing complexity and partly to distribute programming tasks among teams of engineers to speed up the development process.

image name

Figure 1: Conventional compilation.

Compilers generate code in the same way, individually compiling each module into an independent sequence of low-level machine instructions, without any knowledge about what is in the other modules. Once all the modules are compiled, a linker links the modules together, along with any code being used from precompiled libraries.

The drawback of this approach is that the compiler never has complete information about the program being compiled. The "global" optimization claimed by many vendors is done only within single modules. There is no optimization across all program modules, which leads to the suboptimal allocation of the stack, registers, and memories.

1 • 2 • 3 • 4 Next Page Last Page

Comment on "Compilation techniques for PIC32"
*  You can enter [0] more charecters.
*Verify code:


Visit Asia Webinars to learn about the latest in technology and get practical design tips.


Go to top             Connect on Facebook      Follow us on Twitter      Follow us on Orkut

Back to Top