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

about start.a51 files

i trying to understand startup files, here an example
start_mx.a51

;----------------------------------------------------;  START_MX.A51:  This code is executed after processor reset.
;  You may add this file to a uVision2 project.


according to this defintion, always after reset this codes will execute

here is an another part:

PDATASTART      EQU     0H      ; the absolute start-address of PDATA memory
PDATALEN        EQU     0H      ; the length of PDATA memory in bytes.


for example if i determine program data memory 100H PDATALEN EQU 100H ;

IF PDATALEN <> 0
                MOV     R0,#PDATASTART
                MOV     R7,#LOW (PDATALEN)
                CLR     A
PDATALOOP:      MOVX    @R0,A
                INC     R0
                DJNZ    R7,PDATALOOP
ENDIF


according to this code all the program memory will clear after reset. why this codes necessary? why the programmers wants clear their program memory, if i clears program memory , program dosent work. is it true?

Parents
  • "according to this code all the program memory will clear after reset."

    No - all the data memoyr will be cleared!

    "why this codes necessary?"

    'C' specifies that memory should be initialised to zero.

    "why the programmers wants clear their program memory"

    Usually, it's nice to have memory start at some known "clean" state.
    It's not essential - that's why the source code is there for you to modify as you wish!

    "if i clears program memory , program dosent work. is it true?"

    If you really do clear program (ie, CODE) memory, then the microcontroller will have no program to run!

    If your program doesn't work after this initial RAM clear, it probably means you have a bug; eg, using uninitialised variables...

    If you mave memory-mapped peripherals, you may need to exclude their addresses from being cleared...

Reply
  • "according to this code all the program memory will clear after reset."

    No - all the data memoyr will be cleared!

    "why this codes necessary?"

    'C' specifies that memory should be initialised to zero.

    "why the programmers wants clear their program memory"

    Usually, it's nice to have memory start at some known "clean" state.
    It's not essential - that's why the source code is there for you to modify as you wish!

    "if i clears program memory , program dosent work. is it true?"

    If you really do clear program (ie, CODE) memory, then the microcontroller will have no program to run!

    If your program doesn't work after this initial RAM clear, it probably means you have a bug; eg, using uninitialised variables...

    If you mave memory-mapped peripherals, you may need to exclude their addresses from being cleared...

Children