Skip to main content
Visitor II
March 30, 2011
Question

COSMIC and OPTION_BYTE

  • March 30, 2011
  • 3 replies
  • 1018 views
Posted on March 30, 2011 at 15:48

COSMIC and OPTION_BYTE

    This topic has been closed for replies.

    3 replies

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:12

    A solution can be to embedd C source code for option byte programming at the beginning of your project:

    /* Define FLASH programming time */

        FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);

     /* Unlock Data memory */

        FLASH_Unlock(FLASH_MEMTYPE_DATA);

    /* Program value and complement value at adress and address + 1 */

        FLASH_ProgramByte((add), val);

        val_comp = (u8)(~val);

        FLASH_ProgramByte((add + 1), val_comp);

     brazov2

    Hello all !

    I'm trying to preinit my MCU's OPTION_BYTE to create a binary with the OPTION_BYTE allready set !

    This work fine with a assembly file in Ride7 with raisonnance compiler, but now i'm trying to do the same thing with ST Visual Develop and Cosmic compiler but I don't work !

    Of course a find pseudo-solution, but I want a solution without modifying the linker command file (this isn't a profesionnal solution !)

    I don't agree with the other solution trough STVP, because my code will be shared I prefer something in a assembly file or C source to avoid mistake instead of a extra manipulation ! And I prefer something who work in debug mode too !

    Please help me !

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:12

    typo error: instead of FLASH_ProgramByte use FLASH_ProgramOptionByte

    brazov2

    From: brazov.ajeje

    Posted: Thursday, March 31, 2011 11:39 AM

    Subject: COSMIC and OPTION_BYTE

    A solution can be to embedd C source code for option byte programming at the beginning of your project:

    /* Define FLASH programming time */

        FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);

     /* Unlock Data memory */

        FLASH_Unlock(FLASH_MEMTYPE_DATA);

    /* Program value and complement value at adress and address + 1 */

        FLASH_ProgramByte((add), val);

        val_comp = (u8)(~val);

        FLASH_ProgramByte((add + 1), val_comp);

     brazov2

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:12

    Thanks but I found by myself what i'm looking for !

    Here is my code :

    #pragma section const {OptionByte}

        const struct OPT_struct OPTION_BYTE = {0x00, 0x00, 0xFF, 0x02, 0xFD, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF};

    #pragma section ()

    You need to add this new section in your lkf file, forget hand modification, goto Project -> Settings -> Linker -> Category : Input

    Add a Segment and add a sub section, enter address of start and end.

    Set the option of the section to -k to avoid linker optimisation, the linker will keep this unused section.

    The final binary fille will include the OPTION_BYTE set according to your need !

    0690X00000602hLQAQ.jpg