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

Initializing Static Variables in External RAM

Greetings:

I'm sure this has been dealt with before in this forum, but my searches are only yielding vague hints at solutions. Here's the problem: our LCP2292 application in CARM requires external RAM owing to its' copious data appetite.

I've already found that PINSEL0, 1, and 2 must be setup in Main() before any function calls. External RAM is not yet accessible and return address are simply not capable of being pushing on the stack. For example, setting the pin selects in the first subroutine called, init(), wont cut the mustard as the stack's return address is garbage. Like many problems, it is intuitively obvious to even the most casual observer (in hindsight, anyway). I have just carried this observation to the next step and realized that any variables declared "static" with an initial value assignments will also fail to be initialized for the same reason.

Obviously, the pin selects must be setup real early in program execution, long before Main() begins execution. Is there any means to do this from the IDE, or is this going to force me into startup.s and the assembler (a somewhat daunting proposition)? There are discussions of a file "init.A51". Does this file address this issue for that processor, and is there a similar sample for the LCP2292 or the ARM in general?

Thanks for any help you can provide.

Doug Paulsen

  • I may have solved my own problem. Snooping around in my Startup.s, I inserted the following code right after the interrupt vectors are setup. This seems so solve my immediate problem (I just hope I'm not breaking something else...).

    // Reset Handler
    
    Reset_Handler:
    
                    LDR     R0, =0xE002C000				//LCP2292 PINSEL1
                    LDR     R1, =0x80050055				//LCP2292 PINSEL1_Val
                    STR     R1, [R0]
    
                    LDR     R0, =0xE002C004				//LCP2292 PINSEL2
                    LDR     R1, =0x25400000				//LCP2292 PINSEL2_Val
                    STR     R1, [R0]
    
                    LDR     R0, =0xE002C014				//LCP2292 PINSEL3
                    LDR     R1, =0x0FE149E4				//LCP2292 PINSEL3_Val
                    STR     R1, [R0]
    
    

    Do note, however, that the pin select address and values are hard coded here (generally a poor design idea). They'll either need adjusting for different micros and hardware, or is there an assembler .inc file out there somewhere? I'll deal with that later.

    Doug