_system_pre_init

Sysprogs forums Forums VisualGDB _system_pre_init

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #846
    Anonymous
    Participant

    When using Code Composer I can create a function called _system_pre_init which will get called before the main function is called. Inside the _system_pre_init I can stop the watchdog for example.

    Does anyone know how to setup the _system_pre_init in VisualGDB?

    #3220
    support
    Keymaster

    Hi,

    First of all, VisualGDB uses the mspgcc compiler to build code for msp430, so many tricks that work for gcc/mspgcc will work with VisualGDB.
    Regarding the initialization code, you need to make a separate function and put it to one of the .initX sections:

    	;; .init0 (_reset_vector__: Start here after reset)
    ;; .init1 (User definable)
    ;; .init2 (__init_stack: Initialize stack)
    ;; .init3 (__low_level_init: Initialize hardware; user definable)
    ;; .init4 (__do_copy_data; __do_clear_bss: Copy data to .data, clear bss)
    ;; .init5 (User definable)
    ;; .init6 (__do_global_ctors: C++ constructors)
    ;; .init7 (User definable)
    ;; .init8 (User definable)
    ;; .init9 (main)
    ;; .fini9 (__stop_progExec__: Falls into here after main(). User definable)
    ;; .fini8 (User definable)
    ;; .fini7 (User definable)
    ;; .fini6 (C++ destructors)
    ;; .fini5 (User definable)
    ;; .fini4 (User definable)
    ;; .fini3 (User definable)
    ;; .fini2 (User definable)
    ;; .fini1 (User definable)
    ;; .fini0 (_endless_loop__: Infinite loop after program termination)

    E.g. the following function will be placed to .init5 and hence will be executed after copying data from FLASH to RAM but before invoking C++ constructors :

    void __attribute__((naked, section(".init5"))) MyInitializationCode()
    {
    asm("nop");
    }

    Note that the function body will be “copy-pasted” into the initialization sequence, hence the function should not contain any prologue/epilogue and must be declared as ‘naked’ (it may call other functions though).

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.