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

C51: The file order in the project causes errors.

I have problems with startup file, in this article http://www.keil.com/support/docs/2263.htm keil suggest that STARTUP.A51 should be last file in the project (should be linked as last)
But in my project, when STARTUP.A51 is on any other position than first, it cause problems which make my uC reset few times per hour.

Does anybody had such a problem?

I'm using:
IDE-Version: µVision V4.60.6.10
Toolchain: PK51 Prof. Developers Kit for SiLabs Version: 9.51

Best regards,
Marcin

Parents Reply Children
  • I know that the STARTUP.A51 file must be last or next-to-last. That was configuration I start with.
    I wouldn't write this question if my project behaved according to the instructions.

    Maybe I will describe my problem in other words:
    In reference to article http://www.keil.com/support/docs/2263.htm, project should behave different when STARTUP.A51 is on last position (like it should be) and when it's anywhere else (where it shouldn't be).
    But in my project, it behave different only when it is on first position. The worst is that, it work correct only when STARTUP.A51 is on first position.

    We had strange problems beetween two revisions of software, to find out what is the cause, we compared 2 revision of project line by line, change by change.
    Position of startup file cause this problems and the project works correctly only if the position of this file is incompatible with the instructions.

  • do you have any code that specifies location?

  • Can you tell us if you have any code in your project that specifies location?

  • Yes, there is a code that reserve space in memory, set CRC value and flash protection.

    CSEG AT 17FEh
    ProgCRC: DW 4D67h
    
    // conf memory
    CSEG AT 1800h
    ConfMem: DS 1024
    
    CSEG AT 1DFFh
    FlashProtection: DB (~(12))     // First 6KB locked -> 12 pages, 512B each
    
    CSEG AT 1E00h
    ReservedFlash: DS 512           // last page of flash
    
    END
    

    The above code is located in separate .a51 file that is linked as last file, in the configuration which behave correct (where Startup.a51 file is linked as first).

  • I would be inclined to take a close look at the map files and in particular check the differences between working and failing.

    Zeusti

  • 15.1.1. Flash Lock and Key Functions
    Flash writes and erases by user software are protected with a lock and key function. The Flash Lock and Key Register (FLKEY) must be written with the correct key codes, in sequence, before Flash operations may be performed. The key codes are: 0xA5, 0xF1. The timing does not matter, but the codes must be written in order. If the key codes are written out of order, or the wrong codes are written, Flash writes and erases will be disabled until the next system reset. Flash writes and erases will also be disabled if a Flash write or erase is attempted before the key codes have been written properly. The Flash lock resets after each write or erase; the key codes must be written again before a

    so, when

    CSEG AT 1DFFh
    FlashProtection: DB (~(12))     // First 6KB locked -> 12 pages, 512B each
    


    get written, to memory you are hosed as far as writing the rest of your code