This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ECALL from C code.

I'm using the Philips 51MX chip (P87C51MB2)
and trying to make sense out of how to
do an extended (23-bit) ECALL or EJMP
using the Keil compiler. I'd very much
like to have this call generated from 'C'
as my emulator will allow me to debug the
code in 'C'. If I use the SRC directive
to generate assembly code from my 'C'
(in order to insert an ASM statement),
then the emulator will only allow debugging in assembler.

I've tried some variations on the example
in the manual for generating a call to
a hard-coded address, but the example is based on the 16-bit addressing of the 8051 and doesn't generate an ECALL.

Can someone give me an example? Or will I
have to wait for a bug fix from Keil?

Thanks,

--Ed

  • Are you using ROM(HUGE)?

    Take a look in the \KEIL\C51\EXAMPLES\PHILIPS 80C51MX\C LINEAR ROM folder. The C code there generates ECALLs.

    Jon

  • If I use the SRC directive
    to generate assembly code from my 'C'
    (in order to insert an ASM statement),
    then the emulator will only allow debugging in assembler.

    That is an unfortunate and unavoidable consequence of the Keil implementation of the "asm in C"

    Erik

  • I'm avoiding ROM(HUGE) because I understand
    it will cause performance issues.

    Is that true? Is it the only way to
    generate ECALL?

    BTW, the other reason I don't want to use
    SRC is because I'm using the second UART
    on the Philips MX chip - UART1, and
    there appears to be a bug in the assembler
    that it doesn't correctly address all
    the registers when compiled with the
    SRC directive.

    I've talked with and sent to Keil my
    source code on this issue, but heard
    nothing back.

    I'd also rather not put the ASM ECALL into
    another file and call into that file,
    as in my case I'm putting a routine in
    RAM in order to reprogram the main flash.
    So, I don't want to put two routines in there
    and fix up the call to the second one.

    Thanks for your replies,

    --Ed

  • I'm avoiding ROM(HUGE) because I understand it will cause performance issues.

    Those performance issues are that ECALLs are used (instead of LCALLs).

    As far as SRC problems. I haven't heard of any. Are you assembling the SRC file with the AX51 assembler or the A51 assembler?

    Jon

  • I believe I'm using AX51, as I'm using
    Keil version 7.01 with the Philips MX
    part. I can't check as I'm not at work.

    Does it make a difference?


    BTW, I appreciate you guys helping me
    with this, this has been a tough nut
    to crack.

  • Oops, sorry. When you select a Philips MX device, AX51 is always used. AX51 is required for MX51 applications. The A51 Assembler doesn't know about the MX51 instructions.

    Jon

  • Well, I found a workaround for my problems.
    Turns out there is a bug in the AX51 assembler that I've reported to Keil.

    The bug goes like this - I defined some
    bit definitions for the S1CON register,
    to easily access such things as TI_1 and
    RI_1. Keil defined this extended SFR address, but not addresses for the bits.
    Anyway, compiling the code with the C compiler directly into machine code produced
    the correct binary which worked fine. But
    when I just turned on the SRC directive the
    same code stopped working because the instructions were now refering to S0CON,
    not S1CON.

    The workaround is to mask off these bits
    from S1CON, rather than set up the direct access definitions, such as S1CON^1.

    So, now I can use SRC and embed ECALL/EJMP
    into my code.