Question

I'm using Visual Studio for writing desktop applications, and I find it very user friendly and easy to use.

If possible, I also want to write embedded code in Visual Studio. For example, is it possible to generate .hex files for PIC18Fxxx series with C18 or any other similar C-based language?

Was it helpful?

Solution

Unfortunately, there is no official support for PIC by Visual Studio. And, I didn't ever hear that someone has made this in an "unofficial" way. There have always been rumors and speculations about such a feature, but never get a chance to be realized. So, the answer is "no", there is no way of compiling .hex file with the standard Visual Studio IDE.

OTHER TIPS

I do a lot of development with embedded systems, including PIC, and for the most I use Visual Studio, mainly because I like VIsual Assist for C work.

What I do is multi target.... so I compile the code for the PC and use unit testing tools to test the code http://code.google.com/p/seatest/

This means putting stubs in place for all the PIC related hardware

Then you can either trigger off build tools via the TOols menu, or you swap to a native IDE ( like MPLAB) for debugging on the device

Visual Studio (specifically Visual C++) can be used as a code editor for any code for any target, but as complete IDE it falls short.

MPLAB has the ability to output a makefile for the project. You can then use this in Visual Studio by creating a "Makefile Project", and entering the build command. The makefile MPLAB generates is compatible with GNU make rather than MS nmake, you will have to install that too. To make full use of Visual Studio's code navigation and intellisense features, you must add all the project headers and sources to your Visual Studio project - these do not affect the build, but they will be parsed for source browsing, auto-completion etc. Any command-line or compiler pre-defined macros your project uses should also be added to the build settings, and the path to any compiler and additional library header folders should also be added to the project includes.

This works well and allows you to edit and build your code, but is probably only worth doing for large projects. The compiler output may need some massaging to place it in the format that VS understands so that for example clicking on an error message takes you to the appropriate file/line. I have used the GNU sed utility to do that in the past. You still have to launch MPLAB to load and debug your code; if open Visual Studio will pick up any changes you make in MPLAB automatically (just remember not to make unsaved changes in both environments!).

The problem with this approach is that the is no way to sync teh MPLAB project with the VS file set and settings - you have to do that manually.

Another problem is that for some reason, the makefile that MPLAB generates does not include the post/pre biuld steps in a project setup. You can modify the makefile by hand or create a batch file that does pre/make/post steps and call that instead of plain make in your project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top