how can i run the program on pic 18f2550 - c

I wrote a program with c and compile it, I used the mingw.Now I need run the program on pic 18f2550!I've never worked with microcontroller.What should I do?

First, you can't run the object file you have directly on your PIC.
Your PC and microcontroller don't have the same architecture.
So you need to compile your code with the right compiler.
I advise you to install MPLAB for free here : https://www.microchip.com/pagehandler/en_us/devtools/mplabxc/
The IDE comes with the great compiler.
Also, you must have a JTAG programmer to put your firmware onto the PIC...

Related

"windows.h" Not Found Using Eclipse SPARC bare-C Compiler

OK, so I am trying to connect an emulated (Through TSIM) LEON3 processor to a UART terminal. If I am not mistaken I believe I need to compile a C program to enable it to talk with a terminal as I am having difficulties doing it another way.
I found some source code for UART communication here and it all seems to be OK.
However, I am having issues compiling it using the SPARC Bare C Toolchain in Eclipse as it is saying that the windows.h file does not exist. Now I know it exists as I've compiled it successfully using the GCC Toolchain and can't find any similar cases on the web as to why this would be happening.
Is there anyone out there who has had a similar problem or knows the solution?
Additionally, if you know me to be doing the wrong thing in regards to the LEON3 UART comms, please let me know and I will just leave.
Thanks.
BCC is a cross compiler targeting standalone, LEON3- and LEON4-based environments. As a cross compiler, its job is to build binaries for a different environment than the one in which it runs.
Relevant header files describe functions available to a program in its runtime (target) environment. Build-environment libraries and their headers are irrelevant when cross compiling because the build and target environments differ. BCC is correct to expose only the headers for the environment for which it compiles, and that environment does not provide Windows API functions. If the code you're trying to build depends on the Windows API, then you'll need to modify it to remove that dependency, or else find something different.
On the other hand, I strongly suspect that you're going about this whole thing the wrong way. In particular, when you say,
I believe I need to compile a C program to enable it to talk with a terminal
it sounds like you think you're going to build some kind of helper program, but if that's your idea then either you're building it for the wrong environment or you have the wrong idea altogether.
If you want a Windows program that talks to the emulated machine, then you should be building that as a Windows program, and BCC doesn't do that. In that case, you should be using MinGW's gcc, or another C compiler for the emulator's host environment. Moreover, the host-side interface to the emulated environment's UART is an aspect of the emulator. I haven't a clue what emulator you're using, but it might not present the host (Windows) side of that interface as a UART, and it might not require using the Windows API at all.
Or if you indeed do intend to build a program for the standalone LEON3 target environment, then you need to understand that when it runs, it will be the only program that will be running in that environment. That's what "standalone" means -- no OS underneath, therefore no separate processes, and often not even multiple threads of execution. Thus, you do not need a helper program; you just need a program.
The BCC documentation talks about the libraries available there, and in particular, it describes how in that environment, file I/O is allowed only on the standard input and output streams, which are mapped to UART A. Thus, if you use BCC to build the program to run in the emulator, then you don't need to do anything special on that end to talk to the UART. You just use stdio functions directed at stdin and stdout.
On the third hand, if you are running an actual operating system in your emulated environment, then to build programs that run on it you should be using either a native compiler for that environment, in that environment, or else a cross compiler targeting that hosted environment. Either way, BCC is not such a compiler, but GCC might be. Anyway, since Windows does not run on LEON3, it's safe to say that if this is what you're trying to do then you still need something that does not depend on the Windows API.

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

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..?
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.
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.
There are 2 types of compilers
Native
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.

Compiling Programs with arm-none-eabi

first timer here, just wanna ask what happens if you compile something designed for a specific board like say raspberry pi but instead of using those compiler targets you use arm-none-eabi? Will it break the software or what?
If your intent is to build a user space program that will execute on a Raspberry Pi running Linux, then arm-none-eabi is not the right toolchain to use because it has no libc (and it lacks other libs as well). You will not be able to build your application.

Why can't programs compiled using GCC be run using DOSbox while those compiled using Borland(Turbo C) can?

Years ago,I had created a program using TurboC IDE and This program can also be run using DOSbox. Now,when I tried to run any program which was compiled using GCC in DOSbox,this message came:
This program cannot be run in DOS mode
So my question is,Why isn't it possible to run programs compiled using GCC in DOSbox,while those compiled from TurboC are?
PS:The reason that I want to run them in DOSbox is that I want to run those programs in my phone(which has DOSbox installed).
Because MS DOS is 16-bit operating system and has no support for the 32-bit programs. Also modern operating systems has much stricter view on the direct hardware access, so modern programs must work through some hardware abstraction layers, which are also missing in the MS DOS.
There is a GCC distribution called "DJGPP" which enables programs to be compiled using GCC, and uses DPMI to achieve this. Dos Protected Mode Interface, you have to run the program in protected mode, basically. There are other C environments such as Watcom that did the same thing, but I don't think Borland ever did anything with it.

Simulating Circuits and Programming Micro-controllers over Linux

I'm about to go through a Micro-Controller project which controls a robotic arm. My problem is that # MS Windows there are MikroElectronica (IDE: MicroC) compile .c to Hex put the hex in Proteus and simulate. Then using a special (PCB) Kit with CD (carries windows software) I would put the microchip and install the hex file or what ever.
First all the respect to Ms but I just hate it! I adore Ubuntu/linux and open-source I need from the experts to tell me in "Steps" how to do the previously mentioned in linux with minimal complications.
The Electrical and Mechanical Engineers along with me always brag about Ms is easy. I want to show them how Computer Science guy uses open-source technology and how strong and reliable it is.
Please help !
You wish to demonstrate the power of Linux by trying to run products designed for another operating system on it? Chances are those tools may work in Wine.
Or maybe you can use Hi-Tech C as a compiler and try gEDA for simulation. It is also possible to compile Microchip C30 on Linux if you are working on 16-bit PIC:s. In any case, this may not be as easy as using the out-of the-box Windows tools. It will be more educational, nevertheless.
If you can be flexible and opt for AVR then you will have free GCC compiler and programming tools. All open source and Linux/Mac friendly. More info at www.avrfreaks.com.
Here is a compiler, linker and simulator tutorial for PIC on linux. Here is one that uses SDCC c compiler. Google throws out lots of websites when you search for linux pic.
From my side, I cross-compile and program Microchip dsPIC from Linux but it is not really straightforward. Here are the big steps
First I built the C30 toolchain from Microchip sources (you need to apply a few patches on the given sources for it to compile).
Once you have the toolchain binaries, you will need to have the specific Microchip MCU resources. Those are coming with the C30 installation on a win32. I copied those files from the Windows installation folder onto my linux filesystem.
Here you should be able to compile and link some C & ASM code to a hex file through command line.
Second step, I wanted to build my projects within the Eclipse IDE. To do that we "just" had to write a couple makefiles to call our new C30 toolchain.
Third step, program the .hex onto your microchip MCU. Two ways to do it. If you have a Pickit2, Microchip provides a command line tool to play with it. I personally have an ICD2 programmer. I use the command line tool provided in the Piklab project.
Now I don't have any facility to debug with my ICD2 under Linux.
Now Microchip provides an alternative IDE with "Mplab X" which is based on Netbeans (sick) and should work under Linux and MacOS. But this project seemed to be yet under development, I don't know if it is really usable.

Resources