1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Pic 32 and Mplab X

Discussion in 'Microcontrollers' started by be80be, Jun 2, 2017.

Tags:
  1. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    Been playing at this can't figure what I missing here
    Code (text):
     
    CLEAN SUCCESSFUL (total time: 423ms)
    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory 'C:/Users/USER/MPLABXProjects/blink32.X'
    make  -f nbproject/Makefile-default.mk dist/default/production/blink32.X.production.hex
    make[2]: Entering directory 'C:/Users/USER/MPLABXProjects/blink32.X'
    In file included from main.c:4:0:
    c:\program files\microchip\xc32\v1.43\pic32mx\include\lega-c\plib.h:41:30: fatal error: peripheral/adc10.h: No such file or directory
     #include <peripheral/adc10.h>
                                  ^
    compilation terminated.
    "C:\Program Files\Microchip\xc32\v1.43\bin\xc32-gcc.exe" -g -x c -c -mprocessor=32MX250F128B -MMD -MF build/default/production/main.o.d -o build/default/production/main.o main.c -DXPRJ_default=default -legacy-libc
    nbproject/Makefile-default.mk:111: recipe for target 'build/default/production/main.o' failed
    make[2]: Leaving directory 'C:/Users/USER/MPLABXProjects/blink32.X'
    nbproject/Makefile-default.mk:84: recipe for target '.build-conf' failed
    make[1]: Leaving directory 'C:/Users/USER/MPLABXProjects/blink32.X'
    nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
    make[2]: *** [build/default/production/main.o] Error 1
    make[1]: *** [.build-conf] Error 2
    make: *** [.build-impl] Error 2

    BUILD FAILED (exit value 2, total time: 1s)
     
    Code (text):

    #include <stdio.h>
    #include <stdlib.h>
    #include <xc.h>
    #include <plib.h>

    #define SYS_FREQ         (80000000L)

     main() {
        SYSTEMConfig(SYS_FREQ, 0);
       
        mPORTAClearBits(BIT_0);                    //Clear bits to ensure light is off.
        mPORTASetPinsDigitalOut(BIT_0);            //Set port as output

        int i;
        int j;
       
        while(1) {                                //This loop determines the initial time between blinks.
           
            j = 100000;
           
            while (j){                            //This loop controlls how quickely blinking speeds up.
                mPORTAToggleBits(BIT_0);        //Toggle light status. (Can be viewed in LATA SFR)
               
                i = j;                            //Time to wait in between toggle.
                while(i--) {}                    //Kill time.
               
                j = j - 1000;                    //Increase constant to increas blinking speed faster.
            }
        }
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,163
    Likes:
    909
    Location:
    Rochdale UK
    Your plib.h isn't pointing to the right place..

    Is the legacy peripheral library installed???
    Have you got MPLAB 32-suite installed... These are the libraries then are on about.
    http://www.microchip.com/mplab/compilers

    Select downloads and right at the bottom... Pic32 legacy peripheral librabray - windows.
     
  3. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    There Installed it still can't find them you can see them but its not using them blink.png
     
    Last edited: Jun 3, 2017
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,163
    Likes:
    909
    Location:
    Rochdale UK

    Your error states!

    c:\program files\microchip\xc32\v1.43\pic32mx\include\lega-c\plib.h:

    If this directory is incorrect, you need to sort it..

    The bit that gets me is that the libraries aren't even used in your code?? Just delete that line..
     
  6. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    That helped some lol but I still don't understand this is a sample code for microstick
    Code (text):

    CLEAN SUCCESSFUL (total time: 120ms)
    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory 'C:/Users/USER/MPLABXProjects/blink32.X'
    make  -f nbproject/Makefile-default.mk dist/default/production/blink32.X.production.hex
    make[2]: Entering directory 'C:/Users/USER/MPLABXProjects/blink32.X'
    main.c: In function 'main':
    main.c:11:18: error: 'BIT_0' undeclared (first use in this function)
      mPORTAClearBits(BIT_0);     //Clear bits to ensure light is off.
                      ^
    main.c:11:18: note: each undeclared identifier is reported only once for each function it appears in
    make[2]: *** [build/default/production/main.o] Error 1
    make[1]: *** [.build-conf] Error 2
    make: *** [.build-impl] Error 2
    "C:\Program Files\Microchip\xc32\v1.43\bin\xc32-gcc.exe" -g -x c -c -mprocessor=32MX250F128B -MMD -MF build/default/production/main.o.d -o build/default/production/main.o main.c -DXPRJ_default=default -legacy-libc
    nbproject/Makefile-default.mk:111: recipe for target 'build/default/production/main.o' failed
    make[2]: Leaving directory 'C:/Users/USER/MPLABXProjects/blink32.X'
    nbproject/Makefile-default.mk:84: recipe for target '.build-conf' failed
    make[1]: Leaving directory 'C:/Users/USER/MPLABXProjects/blink32.X'
    nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

    BUILD FAILED (exit value 2, total time: 930ms)
     
     
  7. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    Oh lol v1.43 I have v1.40
    I think I figured this out the microstick sample for the 33 and 24 chips works fine but the 32 chips
    I don't have all the needed files to rebuild the proj guess I'll just read the datasheet and start from scratch
     
    Last edited: Jun 3, 2017
  8. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    mPORTAClearBits if I can find the file for this Id be in business

    It's not in there no more PIC32MX250F128B processor header

    So here's the problem
    Warning: Project "BlinkLED" refers to file "C:\Users\USER\Desktop\MicroStickII PIC32 Code Example (3)\MicroStickII PIC32 Code Example\BlinkLED.c" that contains spaces or odd characters in its name or its path.
    Some of the files in this Project "BlinkLED" contain spaces or odd characters in their name or their path. This could potentially cause issues during the build process. This is a limitation of GNU Make tool that we use as part of our build process. Removing spaces from all file and folder names included in this project will eliminate this potential issue.
     
    Last edited: Jun 3, 2017
  9. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,163
    Likes:
    909
    Location:
    Rochdale UK
    All the definitions are in ports.h..
     
  10. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    Ok Ian I spent haft a day looking I don't have a ports.h
    Now in the Pic32 legacy peripheral library there is but like you said I'm not using it it's only used if you add #include <plib.h> I'm using xc32 something wrong with windows 10 and how it installed mplab X

    If I use a pic 33 or the 24 they use the same port stuff like toggle mPORTAClearBits but for some reason xc32 is not

    Whats even funner is that xc32 clearly has plib.h which points to ports.h but no ports.h
     
    Last edited: Jun 3, 2017
  11. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    OK after all day with this I finely got it figured out. The pic32 has way to many setting lol.
    But I got it going with Mplab X v3.35 and xC32.
    The problem is after xC32 1.40 so guess what I have both but mplab just installed 1.43 and when I added the legacy files where do they in 1.40 which has it lol not 1.43 which my mplab ide is using.
     
  12. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    Guess your on your own now days
    Why doesn't this work
    Code (text):
     _LATA0 != _LATA0
    xc 32 doesn't say it's wrong but the led never toggles.
    But if I use the micro for
    Code (text):
     mPORTAToggleBits(BIT_0)
    it works look like both would work.
     
  13. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    261
    Likes:
    15
    Location:
    Helsinki, Finland
    Should'nt it be _LATA0 = ~ LATA0
    bitwise not.
    != means not equal
     
    • Thanks Thanks x 1
  14. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,163
    Likes:
    909
    Location:
    Rochdale UK
    Try _LATA0 = ~_LATA0 This is supposed to be the bitwise op... != is bytewise equality..

    Sorry about the double post!! JJW got there first.
     
    Last edited: Jun 4, 2017
    • Thanks Thanks x 1
  15. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    Now got figure all the crazy naming they got going on
    Code (text):
     _LATA0 =~ _LATA0
    works
     
  16. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,804
    Likes:
    135
    Location:
    morristown,tn
    Got it rolling
     

Share This Page