• AVR Freaks

Hot!Include's added to Main

Author
jtzeng
Super Member
  • Total Posts : 463
  • Reward points : 0
  • Joined: 2003/11/07 12:42:20
  • Status: offline
2019/07/09 08:39:53 (permalink)
0

Include's added to Main

Why are the includes for all the peripherals not included in the main?
I think system.h is, but none of the others.
Is this normal for MCC during generation?
Is there a way to add them during generation?

John Zigrang
JTZ Engineering, Inc.
#1

8 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 2887
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Include's added to Main 2019/07/09 08:47:57 (permalink)
    5 (1)
    Why isn't my application generated completely my MCC?
    Is this normal for MCC ...?

    Honestly: MCC is for starters/to ease controller setup - not intended to do all the work you (may) get paid for...

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    Jim Nickerson
    User 452
    • Total Posts : 6117
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Include's added to Main 2019/07/09 09:56:29 (permalink)
    4 (1)
    I like and use MCC.
    I have used MCC to deliver simple straight forward projects.
     
    My crystal ball says John has added some code and is encountering some errors.
    Once you study the MCC code/h files/help  and understand how it is structured I find it not difficult to add functions/features to make it do what I want.
    #3
    du00000001
    Just Some Member
    • Total Posts : 2887
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Include's added to Main 2019/07/09 10:02:35 (permalink)
    5 (2)
    Most times, the issue is the word understand.
     
    Although the wisdom of your crystal ball might hold.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #4
    Jim Nickerson
    User 452
    • Total Posts : 6117
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Include's added to Main 2019/07/09 10:03:20 (permalink)
    0
    Smile: Smile
    #5
    davekw7x
    Entropy++
    • Total Posts : 1789
    • Reward points : 0
    • Joined: 2012/01/16 12:01:07
    • Location: Left Coast, USA
    • Status: offline
    Re: Include's added to Main 2019/07/09 17:24:32 (permalink)
    5 (4)
    I guess you noticed that your main.c has a statement to
     #include "mcc_generated_files/system.h"

    And then when you try to do something like use one of the I/O macros defined in pinminager.h it can't find it.  At least that's what I found for my PIC24FJ256GA705

    Well, just replace that line with the following and all is well
     #include "mcc_generated_files/mcc.h"


    Now as to why.  I have no connections to Microchip or any of its development team, so I can't say for sure, but I have three guesses:


    • Laziness of people like me who notice little annoyances like this but don't get around to creating a support ticket calling it to the attention of Microchip.  The MCC guys are generally pretty responsive (once it gets past the first support people---but that's another story.)
    • Lack of testing by developers to actually create even the simplest project that uses one of the IO Toggle() macros (defined in pin_manager.h) to blink an LED in a loop paced by __delay_ms().  That would, at least test simplest I/O and clock setup.
      Now, to use __delay_ms() you have to #define FCY and include <libpic30.h> and I don't object to not having that in MCC-generated main(), but I think it's unfortunate that users can't do the simplest blinky project without adding that #include line to main.c.  Not fatal, but annoying.
    • Woeful historical shortcoming of whoever is responsible for releasing software without beta testers (either outside of Microchip or in a Microchip division different from the developers' group) that actually create working projects.  Not even the simplest one to blink an LED.

    Regards,

    Dave


    post edited by davekw7x - 2019/07/09 17:40:54

    Sometimes I just can't help myself...
    #6
    jtzeng
    Super Member
    • Total Posts : 463
    • Reward points : 0
    • Joined: 2003/11/07 12:42:20
    • Status: offline
    Re: Include's added to Main 2019/07/09 17:52:10 (permalink)
    0
    Great update and insight.
    Thanks
     

    John Zigrang
    JTZ Engineering, Inc.
    #7
    hkumar
    Starting Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2012/10/03 01:12:16
    • Location: 0
    • Status: offline
    Re: Include's added to Main 2019/07/09 19:40:02 (permalink)
    5 (2)
    Only the required .h files are included in the main.c by MCC. If the user wants to call any generated peripheral API's then user has to include the required .h files. Yes this is normal.
    #8
    davekw7x
    Entropy++
    • Total Posts : 1789
    • Reward points : 0
    • Joined: 2012/01/16 12:01:07
    • Location: Left Coast, USA
    • Status: offline
    Re: Include's added to Main 2019/07/10 07:11:45 (permalink)
    5 (1)
    hkumar
    Only the required .h files ...
    Yes this is normal.

    Oh, now I get it.  I simply missed the point that for the PIC24 projects the SYSTEM_Initialize function, called from main(), is in its own system.c file with its prototype in system.h. So main.c includes "system.h"
    Whereas, for the 8-bit and 32-bit MCC projects that I  have implemented, SYSTEM_Initialize() is in mcc.c and its prototype is in mcc.h, which includes headers for all of the MCC modules in the project.  So for those projects main.c always includes mcc.h

    I guess that if the MCC guys had included mcc.h in the PIC24 project's main.c, people would have complained about including all of those other headers that weren't needed in the main application.

    Bottom line:
    Thank you for your response, which was more polite than I deserved.
    Now I wish I had simply answered the OP's question about how to include headers for all of the modules (include mcc.h) and reserved my derogatory comments for other MCC "annoyances" that people complain about from time to time. (But sometimes I just can't help myself.)


    Regards,

    Dave

    Footnote: When I was a kid my slightly older brother would tell people that he was the "normal" brother and I was abnormal.  I felt flattered at the time because I thought abnormal meant "above normal."   Some people still think of me as abnormal.


    post edited by davekw7x - 2019/07/10 07:19:47

    Sometimes I just can't help myself...
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5