This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Best Practices for Assembling Suitable sdk_config.h for a Project?

I've read everything I can find in the documentation and on the forum about sdk_config.h.  I also installed the CMSIS configuration wizard.  However I'm still not clear what is the recommended way to assemble an sdk_config.h for for a project that needs a given set of peripherals and libraries.

Every example project has a custom version of sdk_config.h and then the master project has an sdk_config.h with everything defined.

I'm trying to merge the timer_pca1056 (timer blinking LEDs) project and the usbd_cdc_asm_pca10056 (USB UART) projects to use a timer to periorically send messages to the host.  I'm adding the timer code to the usbd_cdc_asm_pca10056 project.  However it did not build because timer symbols are not defined in sdk_config.h.

I carefully found the section in sdk_config.h of timer_pca1056 that defined the timer and pasted it into sdk_config.h of my new project, and now it builds correcty.

However this is tedious and very prone to error.

My question is, when one is defining a new project that uses specific peripherals and libraries, is the recommeneded practise to find the relevant sections of the master project sdk_config.h and assemble a custom sdk_config.h for the new project?  That would be a LOT of work.  How does one know what the relevant sections from the main project sdk_config.h are?  Is there any better way?

I saw a recommendation to include the entire master project sdk_config.h and then use app_config.h for all non-default settings.  Where is app_config.h and how does one add non-default settings to it?  Can anyone refer me to an example project that does it this way?

Also, I see that from looking at master project sdk_config.h with CMSIS that all the peripherals are marked as enabled.  Does this mean that they would be included in a build even if they are not needed?  If not, then what determines if a peripheral's code is included in the build?

What seems to be lacking is an overview of how to use the available tools to create a new project.  How do you experienced users of the SDK do it?

Parents
  • Hi,

    Unfortunately the sdk_config.h files are not complete, and so you do need to copy sections manually when merging functionality from different examples. This is a known SDK bug. Yes, this is tedious and error prone, although the resulting configuration errors typically are easily discovered and easily fixed.

    I saw a recommendation to include the entire master project sdk_config.h and then use app_config.h for all non-default settings.  Where is app_config.h and how does one add non-default settings to it?  Can anyone refer me to an example project that does it this way?

    You just need to create a file named app_config.h and include it at the beginning of sdk_config.h. All defines in sdk_config.h are guarded by ifndefs so that a define is only set if it has not been set previously. That means, you can override anything in sdk_config.h by defining it before sdk_config.h is included. (Or, by defining it in app_config.h and include app_config.h at the very beginning of sdk_config.h.)

    Also, I see that from looking at master project sdk_config.h with CMSIS that all the peripherals are marked as enabled.  Does this mean that they would be included in a build even if they are not needed?  If not, then what determines if a peripheral's code is included in the build?

    What code is included or not is determined by what c files are part of the project. That means you must both add configuration and add the c files for the functionality that you need.

    Regards,
    Terje

Reply
  • Hi,

    Unfortunately the sdk_config.h files are not complete, and so you do need to copy sections manually when merging functionality from different examples. This is a known SDK bug. Yes, this is tedious and error prone, although the resulting configuration errors typically are easily discovered and easily fixed.

    I saw a recommendation to include the entire master project sdk_config.h and then use app_config.h for all non-default settings.  Where is app_config.h and how does one add non-default settings to it?  Can anyone refer me to an example project that does it this way?

    You just need to create a file named app_config.h and include it at the beginning of sdk_config.h. All defines in sdk_config.h are guarded by ifndefs so that a define is only set if it has not been set previously. That means, you can override anything in sdk_config.h by defining it before sdk_config.h is included. (Or, by defining it in app_config.h and include app_config.h at the very beginning of sdk_config.h.)

    Also, I see that from looking at master project sdk_config.h with CMSIS that all the peripherals are marked as enabled.  Does this mean that they would be included in a build even if they are not needed?  If not, then what determines if a peripheral's code is included in the build?

    What code is included or not is determined by what c files are part of the project. That means you must both add configuration and add the c files for the functionality that you need.

    Regards,
    Terje

Children
Related