Embedded, Is it not possible to compile PIC controller using AVR/8051 compiler

433 views Asked by At

How can I compile a different micro-controller on different micro-controller family IDE/compiler.

For example, I have 8051 keil uVision IDE. I need to compile the code for PIC or AVR controller. Is it possible, by changing any internal settings in the IDE? Or by adding Controller specific header files etc.?

The Actual answer i required here is,

what the IDE/compiler will add to the code after selecting a particular "Microcontroller" in device list of keil or AVR Studio or PIC etc..?

3

There are 3 answers

3
Vagish On BEST ANSWER

what the IDE/compiler will add to the code after selecting a particular "Microcontroller" in device list of keil or AVR Studio or PIC etc..?

You are getting it wrong. Let's take a different approach:

Think of a C program as a specification for your processor i.e description in human readable language how it should perform sequentially.

Now each processor has different Hardware architecture and different set of instructions to control it.

Normally ,a C compiler will convert the C Code into Assembly (.asm/.a) instructions specified for that particular processor.

So a C Compiler for different architectures is along-together a different compiler.

In Eclipse or IAR tool-chain you use a different compilers for different processors.

5
AudioBubble On

No. PIC and AVR are both separate architectures from the 8051, and as such require entirely different compilers. You cannot convert a compiler for one into another by changing settings or adding header files; they are simply too different.

Keil does not provide compilers for the AVR or PIC architectures; you will need to install another development environment to work with those parts.

0
prasad On

There are 2 types of compilers

  1. Native
  2. Cross compiler

Native On a PC when you write a program in high level language and compiles using let us say "Visual studio" it generates code for microprocessor on your computer. ( Most probably Intel ).

Compiler convert the high level language constructs into machine language of microprocessor.

Cross compiler A cross compiler is compiler which converts the C code into other microprocessor /micro-controller machine language.

Now various tool like Keil uVision, IAR Embedded Workbench , Code Composer Studio which runs on PC but create machine code for micro-controller selected. Every IDE will provide list of processor families and part number which it supports and it compiles C code accordingly.

These IDE provides various features to configure your program output as per the hardware. Start up and INIT.A51 file you have mentioned will do necessary hardware initialization before main() function will start executing your program.

So when you select particular part number from device list compiler checks if compiled output can be run on part mentioned. For example : If your program requires X amount of RAM and controller has less than X amount of memory it will throw compiler error.