Skip to main content
Visitor II
July 31, 2007
Question

Hiware and compiler problem!

  • July 31, 2007
  • 3 replies
  • 863 views
Posted on July 31, 2007 at 19:41

Hiware and compiler problem!

    This topic has been closed for replies.

    3 replies

    Visitor II
    July 28, 2007
    Posted on July 28, 2007 at 10:17

    Hi, I have old project compiled with Hiware. This old project is maked with editor Softec. I want translate my source in Visual Develop of ST.

    Problem! My funcs RAMPA use *int in this mode:

    void Rampa (volatile unsigned int *PWM, unsigned int val, unsigned char flag, unsigned char anta)

    {

    static unsigned int TempPWM;

    TempPWM = *PWM;

    .....

    In old project this function is compiled fine and the code ASM is:

    TempPWM = *PWM;

    LD X,_Rampap3

    LD A,(1,X) <--look this

    LD X,[_Rampap3] <--and this

    LD TempPWM:1,A

    LD TempPWM,X

    In new project, with Visual Develop, with same option for compiler ( FLAGS = -Ms -Cc -Cq -Lasm=%n.lst )

    the function is compiled in this mode:

    TempPWM = *PWM;

    LD X,#1

    CALL Rampa:265

    LD A,([_LEX.w],X) <-- ???

    LD Y,A

    CALL Rampa:265

    LD X,[_LEX.w]

    LD A,Y

    LD TempPWM:1,A

    LD TempPWM,X

    and not compile! I have this error:

    ERROR L2410: Unresolved external __LEX (imported from funcs.o)

    Why the compiler use LEX indirect access? Why the compiler change if I have used same options?

    Advice? :o :) Thanks you!

    Visitor II
    July 30, 2007
    Posted on July 30, 2007 at 08:07

    Hi Marco,

    with my MetroWerks compiler (Version 1.1) I'll get exactly the same assembler code as in your first example.

    In your second example, PWM seems to be a pointer that points to a NEAR variable (16-bits addressing).

    With a subroutine call this behaviour only might appear when using extended large memory model (flag = -Mx) but not when using small memory model(flag = -Ms).

    So please check your memory model - or do you use the code outside a subroutine????

    Regards,

    WoRo

    Visitor II
    July 31, 2007
    Posted on July 31, 2007 at 19:41

    Thanks for your help!

    I have try to change memory model but I have the same error!

    I must change my funcs...I cannot use pointer in my funcs very good for change all PWM register:

    Rampa(&DCR0,... --> void Rampa (volatile unsigned int *PWM,...

    Rampa(&DCR1,...

    Rampa(&DCR2,...

    Rampa(&DCR3,... :-[

    Thanks again! bye