FAQ

FAQ

How to keep the status of SRAM and do not initialize it when chip is reset?  Issue Date:2020-02-07

To take the watchdog reset of M031 as an example.

When chip is reset, CPU will start to run code from “startup_M031Series.s”. In this code, program counter will jump to “startup_M031Series.c” and execute the System_Init function. After executing, the program counter will jump to __main function.

 

LDR    R0, =SystemInit  // Setting R0 as the address of SystemInit

BLX    R0            // Jump to address of R0 and execute Thumb command

LDR    R0, =__main    // Setting R0 as address of __main

BX      R0            // Jump to address of R0

 

__main function is built from compiler automatically. This function will initialize the SRAM. This initialization includes copy RW-data and ZI-data to SRAM, initialize the ZI-data to 0 and so on. After executing the __main, the program counter will jump to __rt_entry function.

__rt_entry function is built from compiler automatically, too. This function will setup the environment of executing the program. The setup includes initialize the Stack, Heap, Library and so on. After executing the __rt_entry, the program founter will jump to main() function.

 

If user wants to keep the SRAM status when chip is reset, it just needs to jump to main() function before entry __main function.

 

extern int32_t main(void);

void SystemInit(void)

{

    /* If the last reset source is WDT Reset, do not reset SRAM */

    if(SYS->RSTSRC & SYS_RSTSRC_RSTS_WDT_Msk)

    {

        main();

    }

    ……

}

282-1

Note: This flow chart is quoted from KEIL website.

 

For detailed description of Startup flow, please refer to KEIL website: http://www.keil.com/support/man/docs/armclang_intro/armclang_intro_
asa1505906246660.htm

Products: Microcontrollers ,8bit 8051 MCUs ,Arm Cortex-M0 MCUs ,Arm Cortex-M23 MCUs ,Arm Cortex-M4 MCUs
Applications:
Function: Peripherals,Memory,SRAM,System Operation,Reset,Timer and PWM,Watchdog Timer (WDT)
This website uses cookies to ensure you get the best experience on our website. Learn more
OK