Getting example code to work with MPLABX - Page 1
Forum section: electronics / general

author: Dajgoro
author_rank: Frequent Contributor
timestamp: November 08, 2013, 07:36:12 pm
content: Hi.I am trying to avoid using MPLABX since it is a mess to use with 8 bit mcu-s.Now I am trying to compile a simple mouse example code for the 18F2550 which I found on the Microchip page:http://www.microchip.com/CodeExamplesByFunc.aspxOf course, when I import the files, none of the includes work, and there is no pic.h.Even when I manually add it, it still won't recognize it.How do I properly import that example to MPLABX v1.60 and compile it?

author: Niklas
author_rank: Frequent Contributor
timestamp: November 08, 2013, 08:00:54 pm
content: Have you imported the project (MPLAB 8.XX to MPLAB X conversion)?I am not completely converted to MPLAB X yet but usually I get help from it with the include files. Start to write #include and see if you will get help from the auto complete to fill in the header file's name. There will be "" or <> around the name depending on where the files are located (your own files or the compiler's files stored somewhere else).If the include files are not found, then they will be underlined with red. Same goes with all definitions, declarations etc that are specified in the missing include file.Right click on the project in the leftmost, project window to display the options like search paths, compiler settings.

author: mazurov
author_rank: Frequent Contributor
timestamp: November 08, 2013, 08:05:05 pm
content: The current MPLABX version is 1.95, you may want to upgrade since it's less buggy than 1.60. The import is still crappy though.

author: Dajgoro
author_rank: Frequent Contributor
timestamp: November 08, 2013, 09:04:42 pm
content: The include of pic.h is always marked red, and a lot of the functions are as well, since it isn't included.I have the pic.h, and all of the includes of the projects, but where do i place them to get them working?I added them to the include library, but that didn't help.

author: andersm
author_rank: Super Contributor
timestamp: November 08, 2013, 09:48:26 pm
content: First off, the syntax highlighting of MPLAB X is terrible, so only trust the compiler's output, not whether the IDE can or can't parse your files. Second, adding a header file to your project does not mean it's added to the compiler's include path. If needed, you add the paths in the project's settings.

author: dannyf
author_rank: Super Contributor
timestamp: November 08, 2013, 10:41:20 pm
content: QuoteYou probably need to figure out what compiler you are supposed to use; from there, if any global defines are used; and then include the right files / folders. After that, providing a project folder would be helpful.

author: Dajgoro
author_rank: Frequent Contributor
timestamp: November 09, 2013, 12:27:56 am
content: I got the C18 compiler.Why can't including files be as easy like in Eclipse when working on a Java project...

author: dannyf
author_rank: Super Contributor
timestamp: November 09, 2013, 12:34:48 am
content: QuoteWhat you are using is far less important than what you are supposed to be using.QuoteBecause they want you to develop a good habit of reading the @#$s() manual first.

author: Dajgoro
author_rank: Frequent Contributor
timestamp: November 09, 2013, 04:32:04 am
content: I've replaced #include <pic.h> with #include <p18f2550.h>, and now it seems to find it, and half of the red markings are gone. I've done that for the rest of the files as well.But there is a still a bunch of errors left, and they are all of the same kind.So for the first line of code after the include section:__CONFIG(0x3F3A);I get the error "unable to resolve identifier", and that error appears on many places, in all of the files.What is missing now?

author: Dajgoro
author_rank: Frequent Contributor
timestamp: November 09, 2013, 10:15:17 pm
content: Turns out that the new compiler works in a different way, and that old code won't work anymore!I saw that #define _LEGACY_HEADERS should be added to make it work, but nothing happens.Where can I find any sort of demo code that demonstrates a usb mouse interface for the 18f2550 that will actually compile?

author: Dajgoro
author_rank: Frequent Contributor
timestamp: November 09, 2013, 10:55:42 pm
content: I now downladed a big package of example code, and of course none of the examples are able to compile, all of the includes have errors!I downloaded it from here:http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en547784#P81_1493Edit: The project include files such as usb.h, but usb.h is nowhere to be found.

author: Dajgoro
author_rank: Frequent Contributor
timestamp: November 10, 2013, 12:59:02 am
content: I reinstalled mplab x, and now it doesn't show the include errors anymore, and I was able to build the code, but when I programmed the pic with the pickit2 and plugged it into the usb port, I just got an unknown usb device message.