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

Ram clear after reset

Hello,
I am working on a project based on STM32F103VC microcontroller. I tried to find any resource/discussion/application note on clearing of internal SRAM after reset (i.e. initialization of SRAM). Although the topic seems trivial, it is strange that I was unable to find any resource nor example. I tried to investigate startup_stm32f10x_x.s files to find relevant routine without success. Could you please provide information/examples/advices how to clear internal SRAM after reset, what is the best way. If it has to be done in the startup file - plese, suggest an example. Could we use memset function called in the initialisation function before main and how to implement it in a problem-free manner (and any examples?)?
Thanks in advance

Parents
  • startup_stm32f1xx.s

    ; ...
    ; Reset handler
    Reset_Handler   PROC
                    EXPORT  Reset_Handler
                    IMPORT  SystemInit
                    IMPORT  __main
    
                    LDR     R0, =0x20000000
                    LDR     R1, =0x2000C000 ; 48KB
                    LDR     R2, =0xE5E5E5E5 ; Fill Pattern
    RAM_Init_Loop
                    STR     R2, [R0], #4 ; *R0++ = R2
                    CMP     R0, R1
                    BNE     RAM_Init_Loop
    
    ; The __main routine resets the stack pointer, and then initialize the static area
    ;  it then CLEARS all the space between there and the stack.
    
                    LDR     R0, =SystemInit
                    BLX     R0
    
                    LDR     R0, =__main
                    BX      R0
                    ENDP ; Reset_Handler
    
    ;...
    

Reply
  • startup_stm32f1xx.s

    ; ...
    ; Reset handler
    Reset_Handler   PROC
                    EXPORT  Reset_Handler
                    IMPORT  SystemInit
                    IMPORT  __main
    
                    LDR     R0, =0x20000000
                    LDR     R1, =0x2000C000 ; 48KB
                    LDR     R2, =0xE5E5E5E5 ; Fill Pattern
    RAM_Init_Loop
                    STR     R2, [R0], #4 ; *R0++ = R2
                    CMP     R0, R1
                    BNE     RAM_Init_Loop
    
    ; The __main routine resets the stack pointer, and then initialize the static area
    ;  it then CLEARS all the space between there and the stack.
    
                    LDR     R0, =SystemInit
                    BLX     R0
    
                    LDR     R0, =__main
                    BX      R0
                    ENDP ; Reset_Handler
    
    ;...
    

Children
No data