Editing Firmware Constants Using Compiler Arguments in PSoC® Creator™ - KBA213561

Version 3

    Version: **


    Translation - Japanese: PSoC®Creator™のコンパイラ引数を使用したファームウェア定数の編集 - KBA213561 - Community Translated (JA)



    How do I edit firmware constants in PSoC Creator using compiler arguments without doing any modification in the code? When will this feature be useful to me?



    When developing certain system level applications, it is common to place various debug code in the firmware. This debug code may involve changing a Components configuration in firmware. Usually, macros are defined to change configurations. You edit the macros to change configurations. However, these macros can be edited during compile time using compiler arguments. This avoids editing of the code.


    Do the following to change the macros during compile time using compiler arguments.


    1. Open your project in PSoC Creator.
    2. Select Project > Build Settings.
    3. In the Build Settings dialog box, select Toolchain as follows: 
      1. For PSoC 3: DP8051 Keil 9.51 or the latest version available
      2. For PSoC 4: ARM GCC 4.9 or the latest version available
      3. For PSoC 5LP: ARM GCC 4.9 or the latest version available
    4. On the left panel, expand the Toolchain that you selected, and then select Command Line from the Compiler group.
    5. On the right panel, select Custom Flags under Command Line, and then select the Edit button next to it.
    6. Declare the value in the format DEFINE (Variable name = value) in the text editor and click OK.
    7. Click OK to close the Build Settings dialog box.


    For example, say your main.c file has the following format and that you are using Keil compiler:


    void main()
           /* Place your initialization/startup code here (e.g. MyInst_Start()) */
                 #if RUN       /* RUN is the macro used in this example */


    You can define the macro RUN using the Custom Flag “DEFINE (Variable name = value)”. So, you add the following text in the Custom Flags text box, as shown in Figure 1:


    DEFINE (RUN=0).



    Figure-1: Defining a value for a firmware constant in PSoC Creator


    If you are using the GCC or MDK compiler, enter the command line argument in the format “–D RUN=0”.