程序和程序中的数据,比如数组里面的数据,这是存在ROM中。这部分数据不会被改变。是常亮。RAM中存储的是变量。在程序运行中会产生和改变的数据。如果一个变量被初始化了,初始化的数据是存在ROM中 ,RAM中只是存了这个数据的地址。如果在运行中改变这个数据,那么ROM中的数据不会被更改。只是RAM数据会更改。
堆栈:
RAM中的变量是存储在一个堆栈中。堆栈是在单片机的启动文件中定义的。
Stack_Size EQU 0x00000400
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT __main
IMPORT SystemInit
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the clock system and also configure the external
;* SRAM mounted on STM3210E-EVAL board to be used as data
;* memory (optional, to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM3 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.