Embedded code development (especially for PIC with C18) in Visual Studio
Asked Answered
A

3

5

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?

Alee answered 16/5, 2012 at 22:11 Comment(1)
See also #4762768Laural
H
2

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.

Huehuebner answered 16/5, 2012 at 22:22 Comment(2)
this is not really so, IronRuby and IronPython and many other things don't run with "standard" VS, but VS is designed to be extended to be used as an IDE for whatever you want and has many different ways to plugin external toolingHeterologous
This probably was not the best answer - unofficial integration with external compilers is more than speculation, people have been doing it for ages.Battlefield
H
7

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

Heterologous answered 16/5, 2012 at 22:27 Comment(3)
I was also thinking about writing a little program that runs the compiler and converts all its output ( warnings / errors ) into visual studio comptaible formats so that you can click on error messages and it will take you to the line of code in questionHeterologous
I did exactly that for a while, to drive gcc for embedded code and capture its errors, but when a 2nd engineer joined the project and felt helpless without source level debugging, ended up switching IDEs to one that would more easily interface with gdb. Ultimately switched development platforms entirely ;-)Battlefield
I've seen that instinct before, usually once you get someone into unit testing, they can source level debug something, on the PC, and for the most, you can get lots of software working very quickly, then occasionally, you need to drop to the native tools to debug on chip ( especially with PIC, since the compiler/s have a habit of generating the wrong code at times face palm )Heterologous
H
2

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.

Huehuebner answered 16/5, 2012 at 22:22 Comment(2)
this is not really so, IronRuby and IronPython and many other things don't run with "standard" VS, but VS is designed to be extended to be used as an IDE for whatever you want and has many different ways to plugin external toolingHeterologous
This probably was not the best answer - unofficial integration with external compilers is more than speculation, people have been doing it for ages.Battlefield
L
2

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.

Laural answered 17/5, 2012 at 15:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.