Hi Dmitry!

[the following holds for IAR C-compiler - not MSP430-GCC]
>>I will decribe the mechanism of "__low_level_init" in detail:
>>Every program written in C starts with the initialisation of the stack
>>pointer SP. Short after this the function "__low_level_init" is
>>CALLed.
>>In default case this function just gives back a return value, but the
>>user can redefine this function for own purpose. After the RETurn, the
>>normal C-preamble is computed (initialisation of global variables,
>>heap...).


actually, there is no stack initialization in __reset_vector.

ACK - the first in the C prologue of the MSP430-GCC is the HOLD command to the watchdog timer.



stack being initialized in the 'main' prologue and can be avoided with '-mno-stack-init' option.

I don't care about stack initialisazions... Maybe you misunderstood me.

My problem ist, that I would like to have some user-specific initialisazions before the automatical generated function _reset_vector__ is executed.


1. use gcc-3.4 and put some code into '.initX' sections

Could you explain in short words, what do you mean?
(I am only a C-newbie. I am a hardware engineer, who knows a possible architecture of the MSP430 and the assembler very well.)


2. make your 'main' doing low_level_init then branch to real main.

This would lead to the fact, that _reset_vector__ is computed first. Then a CALL to a initialisation function would be done and after this, the real body of main would be executed

This is not what I would like to have.

Let me describe in assembler, what I want:

_reset_vector__:
        MOV     #0x5A80,&0x0120             ;hold watchdog (optional)
        MOV     #0x0A00,R1              ;initialize SP
        CALL    #__low_level_init
        ;do all the other stuff
        ;what has to be done
        ;in the C prologue
        ;NOTE:
        ;this should be automatical generated
        ;by the C-compiler
        JMP     main


main:
        ;main program
        ;...


__low_level_init:
        ;do specific low level init
        ;before the C-prologue is computed
        RET


My intention is, to have specific initialisazion at the very first time, because the C-prologue may be too time consuming to do it afterwards (or there are some other reasons...). To achieve this, I don't want to write my own _reset_vector__, because this should be automatically made by the compiler (that can do this better than me).

This mechanism is offered by IARs C-Compiler and called "__low_level_init". So I am asking if there is a similar solution for MSP430-GCC.

Ralf


Reply via email to