Author Topic: Getting example code to work with MPLABX  (Read 8451 times)

0 Members and 1 Guest are viewing this topic.

Offline DajgoroTopic starter

  • Frequent Contributor
  • **
  • Posts: 322
  • Country: hr
    • hackaday.io
Getting example code to work with MPLABX
« on: November 08, 2013, 07:36:12 pm »
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.aspx

Of 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?
 

Offline Niklas

  • Frequent Contributor
  • **
  • Posts: 399
  • Country: se
Re: Getting example code to work with MPLABX
« Reply #1 on: November 08, 2013, 08:00:54 pm »
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.
 

Offline mazurov

  • Frequent Contributor
  • **
  • Posts: 524
  • Country: us
Re: Getting example code to work with MPLABX
« Reply #2 on: November 08, 2013, 08:05:05 pm »
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.
With sufficient thrust, pigs fly just fine - RFC1925
 

Offline DajgoroTopic starter

  • Frequent Contributor
  • **
  • Posts: 322
  • Country: hr
    • hackaday.io
Re: Getting example code to work with MPLABX
« Reply #3 on: November 08, 2013, 09:04:42 pm »
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.
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: Getting example code to work with MPLABX
« Reply #4 on: November 08, 2013, 09:48:26 pm »
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.

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Getting example code to work with MPLABX
« Reply #5 on: November 08, 2013, 10:41:20 pm »
Quote
How do I properly import that example to MPLABX v1.60 and compile it?

You 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.
================================
https://dannyelectronics.wordpress.com/
 

Offline DajgoroTopic starter

  • Frequent Contributor
  • **
  • Posts: 322
  • Country: hr
    • hackaday.io
Re: Getting example code to work with MPLABX
« Reply #6 on: November 09, 2013, 12:27:56 am »
I got the C18 compiler.

Why can't including files be as easy like in Eclipse when working on a Java project...
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Getting example code to work with MPLABX
« Reply #7 on: November 09, 2013, 12:34:48 am »
Quote
I got the C18 compiler.

What you are using is far less important than what you are supposed to be using.

Quote
Why can't including files be as easy like in Eclipse when working on a Java project...

Because they want you to develop a good habit of reading the @#$s() manual first.
================================
https://dannyelectronics.wordpress.com/
 

Offline DajgoroTopic starter

  • Frequent Contributor
  • **
  • Posts: 322
  • Country: hr
    • hackaday.io
Re: Getting example code to work with MPLABX
« Reply #8 on: November 09, 2013, 04:32:04 am »
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?
 

Offline DajgoroTopic starter

  • Frequent Contributor
  • **
  • Posts: 322
  • Country: hr
    • hackaday.io
Re: Getting example code to work with MPLABX
« Reply #9 on: November 09, 2013, 10:15:17 pm »
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?
 

Offline DajgoroTopic starter

  • Frequent Contributor
  • **
  • Posts: 322
  • Country: hr
    • hackaday.io
Re: Getting example code to work with MPLABX
« Reply #10 on: November 09, 2013, 10:55:42 pm »
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_1493

Edit: The project include files such as usb.h, but usb.h is nowhere to be found.
« Last Edit: November 09, 2013, 11:15:50 pm by Dajgoro »
 

Offline DajgoroTopic starter

  • Frequent Contributor
  • **
  • Posts: 322
  • Country: hr
    • hackaday.io
Re: Getting example code to work with MPLABX
« Reply #11 on: November 10, 2013, 12:59:02 am »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf