0 Replies Latest reply on Nov 29, 2013 1:09 AM by kiku

    Placing a constant in an absolute Flash location in PSoC 3 using KEIL Linker commands

    kiku

      A Constant can be placed at an absolute Flash memory location in your C program source codes using the CYCODE keyword. This Keyword will actually place the constant at some random Flash memory location. In order to force the KEIL compiler to place it in a particular Flash memory location, we need to use LINKER command as specified by KEIL:

         

      SE(?CO?<Source_File_Name>(C:<Address_in_Hex>))

         

      Follow the steps mentioned below in order to place a constant at an absolute Flash location:

         

      1.    Create a C Source File in the Workspace Explorer (say foo.c)

         

      2.    Place the variable which needs to be stored in an absolute Flash location in that source file. Include “device.h” header file in it.

                                          

      //contents of foo.c source file

       

      #include <device.h>

      const uint8 code fooarray[10] = {9, 10, 11, 12, 13, 14, 15, 16, 17, 0xAA};

         

      3.    Place the Linker command under Project -> Build Settings -> DP9051 Keil 9.03 -> Linker -> CommandLine (SE(?CO?FOO(C:0X5A5A)) ; Here 0x5A5A is the relative Flash location. Absolute Flash location with respect to the memory map would be 0x01005A5A)

         

         


      4.    Compile the project and verify the placement by looking at the .map file under Results tab of Workspace Explorer

         


         

      Note:

         
            
      1. If you want to place multiple constants at different flash locations in a discrete manner, then a source file has to be created for every constant and corresponding LINKER commands have to be used. As noticed above, flash location is specified only for the complete source file but not for the constant name.
      2.     
      3. If you want to place multiple constants at different flash locations in a continuous manner, then we can place all the constants in a single source file itself and a corresponding LINKER command can be used.
      4.