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

Bootloader Startup.asm code Help

Hi,

I'm starting learning 8051 mcu, came up with the startup code written in assembly.
I have few things I need to know.

Here is the sample startup source code of bootloader:

My questions start with ????? below.


;SOME INITIALIZATION HERE

CSEG    AT      0

?C_STARTUP:     LJMP    Start
                LJMP    ISRApp_ExternalInt0
                LJMP    _WritePageOnFlash
                ds      2 ????? Why reserve 2-bytes?

                LJMP    ISRApp_Timer0
                LJMP    GetP2Value
                ds      2 ????? Why reserve 2-bytes?

                ...

                LJMP    ISRApp_UART1
                ds      10 ????? Why reserve 10-bytes, does it overlap the 8-byte interrupt interval?
                LJMP    ISRApp_SMB1
                ...

CSEG   AT       1400h
Base:                   dw      $
ISRApp_Reset:           lcall   Error ????? Why it calls Error?
ISRApp_ExternalInt0:    lcall   Error
ISRApp_Timer0           lcall   Error

...

ISRApp_UART1            lcall   Error


Error:
      clr EA
Loop:
      jmp Loop


...

END

Also, what I don't understand here is, why it didn't indicate CSEG AT 03h for Interrup 0, CSEG AT 0Bh for Interrup 1, etc. as to what states here http://www.keil.com/support/docs/132.htm?

Hope somebody can lighten me up here.

I used Silabs 8051 mcu w/ keil's C51.

thanks
gee

Parents Reply Children
  • Hi Erik,

    Thanks for your reply.

    what is the relevance between indicating interrupt addresses and an external EEPROM

    What do you mean by this?

    PS there is no reason whatsoever to have ant interrupt addresses in startup.a51

    May I know why?

    How about those bytes reserved after the ljmp?

    I'm sorry for these questions. I just wanted to learn. I tried looking for some documents and it seems non of them explain it and so forum is my last resort.

    I really appreciate your help here.

    thanks in advance
    gee

  • Yes! I did it! I understand now why and what "ds 2 or 5 or sometimes 10" serve after each "ljmp" of interrupt. The answer is in Startup.lst. Since NOIV is used, I should manually calculate the redirected address of each interrupt and ds x compensate for the next Interrupt address, "ljmp" eats 3-bytes and "ds x" should be added to point to the next 8-byte interval of interrupt.

    1 question remains, why all redirected interrupt calls "Error" label?

    Hope somebody can explain me on this.

    thanks in advance
    Gee

  • Sir,

    The calls to "Error" are there for unused interrupts. Their purpose is to catch an unexpected interrupt. That is to say, one that could be generated, but should not be because your code has not enabled it. If it were to occur, you would want to try and catch the unexpected event and maybe report it. The "Error" routine could be used to carry out this trivial, but potentially very useful, operation.

    I trust this response answers your question in a satisfactory manner.

    With kindest regards,

    F. St Jones-Wilson (MILF)

  • 1 question remains, why all redirected interrupt calls "Error" label?

    Hope somebody can explain me on this.

    so, it is someone elses code

  • The first post more or directly told us it was found code, and the OP wanted to understand why the code looked like it did.

    Reading others code is a good way to learn - at least if the one who wrote the code was reasonably skilled. But if reading enough code, it will be easier and easier to recogize good/bad code even if not anyone else points out what is good/bad.

  • so, it is someone elses code

    Is there something wrong with using someone elses initialisation code? I've done it before when I use Keil's startup code. The first time I did it the inquisitive part of me had me wondering what soome parts were about and what they did.

  • Is there something wrong with using someone elses initialisation code? I've done it before when I use Keil's startup code. The first time I did it the inquisitive part of me had me wondering what soome parts were about and what they did.
    no, but it is nice to say so. Using code provides as part of a toolset is more or less mandatory, so there is absolutely nothing 'wrong' with using Keil startup. However the code where unused interrupts go to 'error' is not Keil. Just it is far easier to answer questions if it is known whether it is code downloaded or written by the OP. The problems with downloaded code are (usually) very different fom the problems with own code.

    Erik

  • Sir,

    I trust this response answers your question in a satisfactory manner.
    Thank you very much. Your response answer my question very well.

    And to others who responded my post, I'd like to say thank you all for your time and skills helping others to learn. Very much appreciated.

    regards
    Gee