Read out Start-Up Values of SRAM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Read out Start-Up Values of SRAM

299 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by an.schall on Thu Jan 03 08:39:29 MST 2013
Hi Guys,

I am pretty new to the LPC XPresso board. I would like to read out the values of the SRAM before any initialization of the SRAM is performed.
Therefore I am curious if the startup code, which is available in C-language is also available in ASM. I want to put my costume ASM code in the ResetISR() routine before main() is called. To be more precise, I want to iterate over the SRAM range and print every byte via printf() or send it via USART to a terminal.
This was working fine with STM32VL Discovery board and now I want to achieve it with LPC Expresso. Do you guys have any hints how to do this?

Cheers!
0 Kudos
2 Replies

276 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by an.schall on Mon Jan 07 08:42:25 MST 2013
Hi Brutte,

of course you are right. With initialization of SRAM I meant .data section and the .bss section which gets initialized to 0.
I did not know about the .noinit section before, thanks! However, I want to work with registers only in my routine. My plan is to put something like this before intialization of those sections:

__asm("ldr     r0, =0x40021000\n" ; RCC
 
                "ldr     r1, =0x00004004\n" ; USART1EN | IOPAEN (GPIOA)
                "str     r1, [r0, #0x18]\n" ; RCC_APB2ENR
 
                "ldr     r0, =0x40010800\n" ; GPIOA
 
                "ldr     r1, =0x444444B4\n" ; PA.9 USART1_TX 50MHz AF_PP
                "str     r1, [r0, #4]\n"    ; GPIOx_CRH
 
                "ldr     r0, =0x4001380\n" ; UART1
 
                "movs    r1, #0\n"
                "strh    r1, [r0, #4]\n"    ;  +4 USART_DR
 
                "movs    r1, #69\n"         ; 8MHz / 69 == 115200
                "strh    r1, [r0, #8]\n"    ;  +8 USART_BR
 
                "movs    r1, #0x0600\n"
                "strh    r1, [r0, #16]\n"   ; +16 USART_CR2 = 0x600
 
                "movs    r1, #0\n"
                "strh    r1, [r0, #16]\n"   ; +16 USART_CR2 = 0
 
                "movs    r1, #0\n"
                "strh    r1, [r0, #24]\n"   ; +24 USART_GTPR = 0 - Prescaler
 
                "movw    r1, #0x200C\n"     ; 8-bit, no parity, enable TX,TX
                "strh    r1, [r0, #12]\n"   ; +12 USART_CR1
 
                "ldr     r2, =0x2000\n"     ; Size = Length (8K)
                "ldr     r3, =0x20000000\n" ; Mem = RAM Address
"iu1             ldrh    r1, [r0, #0]\n"    ; USART->SR
                "ands    r1, #0x80\n"       ; TXE
                "beq     iu1\n"
                "ldrb    r1, [r3], #1\n"    ; [Mem++]
                "strh    r1, [r0, #4]\n"    ; USART->DR
                "subs    r2, r2, #1\n"      ; Size--
                "bne     iu1\n") 


Note, this code works with an stm32vl discovery eval board. I did not try it with the lpc xpresso, yet. I guess I'll have to change some commands. Maybe someone who is experienced with ASM and lpc xpresso could help me out with this?

Kind regards!
0 Kudos

276 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Brutte on Thu Jan 03 11:00:53 MST 2013

Quote: an.schall
Hi Guys,
I would like to read out the values of the SRAM before any initialization of the SRAM is performed.


I guess you are talking about .data and .bss sections, as only those sections are initialized at start-up, not the whole ram.
Neither stack nor heap (except for the pointers).

Just put your UART routine before initialization of those sections. Mind that you must not use statically allocated data in there because it will not be initialized. Only autos allowed.

Are you aware that you can put some of your not initialized data into .noinit section?
0 Kudos