8-bit Knowledge Base

      • MCU constantly resets, never reaches the main function, stuck in STARTUP.A51

        BrianL | 07/190/2014 | 10:04 PM


        The MCU appears to never enter the main function of the program. When paused while debugging, it may appear to be in STARTUP.A51 (or SILABS_STARTUP.A51). The MCU appears to be constantly resetting. This may occur after declaring large global variables that are initialized, or after adding one variable to a large amount of global or static variables that must be initialized. Removing some of these variables seems to solve the problem.


        The MCU's watchdog timer, which is enabled by default, is likely expiring and resetting the MCU during INIT.A51. This file runs after STARTUP.A51, but before the main function, and is responsible for initializing all global and static variables. After a certain threshold, there may be so many variables to initialize that the INIT.A51 file does not get through them before the watchdog timer expires.


        The solution is to disable the watchdog timer in assembly within the STARTUP.A51 file. This should be the first instruction that is run, at the STARTUP1: location of the file. The watchdog timer may be disabled in different ways depending on the MCU, but some examples are below.


        F9xx, F3xx, F5xx:

        Equivalent C:

           PCA0MD &= ~0x40;


           STARTUP1: ANL 0D9H, #0BFH


        F85x/EFM8(Except EFM8SB1/SB2/UB2):

        Equivalent C:

            WDTCN = 0xDE; //First key
            WDTCN = 0xAD; //Second key



           STARTUP1: MOV 097H,#0DEH

                                 MOV 097H,#0ADH