Code for reset ram

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

Code for reset ram

1,462 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Mon Jun 07 07:41:32 MST 2010
Do you have a simple code for reset ram in C for 1758.
This code have a warning error [COLOR=#000000]obviously[/COLOR]

void InitRAM (void)
{
  uint32_t *Add=0;

  Add = 0x10008000;

  while (Add > 0x10000000)
    {
    Add --;
    *Add = 0;
    }
}

Thanks
0 Kudos
Reply
8 Replies

1,442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Tue Jun 08 23:22:33 MST 2010

Quote: CodeRedSupport
Incorrect. You can set a breakpoint here, just as you can elsewhere in your code.

There are various ways of doing this, but the simplest is probably just to open the file in the editor view, scroll down to the definition of ResetISR and then double click on the left hand side of the view. When you next load/reload the application, you should then stop when ResetISR starts to execute.

Regards,
CodeRedSupport


OK the break function and the routine run.
At this point I still  doubt the need to clear a variable in its definition that gave me  problems.
But that's another story . . . .
0 Kudos
Reply

1,442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Jun 08 08:28:04 MST 2010

Quote: blasiis
I cannot insert a break in ResetISR routine, correct ?


Incorrect. You can set a breakpoint here, just as you can elsewhere in your code.

There are various ways of doing this, but the simplest is probably just to open the file in the editor view, scroll down to the definition of ResetISR and then double click on the left hand side of the view. When you next load/reload the application, you should then stop when ResetISR starts to execute.

Regards,
CodeRedSupport
0 Kudos
Reply

1,442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Tue Jun 08 05:37:37 MST 2010

Quote: CodeRedSupport
Correct. It is ResetISR() that calls main() !

cr_startup_lpc17xx.c places the address of ResetISR into the second location in the Cortex-M3's vector table - which is the location the processor will start execution from as it comes out of reset.

ResetISR() then
- Copies RW data
- Creates BSS data
- Calls CMSIS SystemInit() function (if appropriate)
- Optionally calls C++ init code (not applicable in LPCXpresso which supports only C)
- Calls main() - either directly, or via Redlib C library initialisation function.

Regards,
CodeRedSupport.


I cannot insert a break in ResetISR routine, correct ?
0 Kudos
Reply

1,442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Jun 08 02:03:00 MST 2010

Quote: blasiis
Ok is this, but it isn't called from main

ResetISR(void) {
   



Correct. It is ResetISR() that calls main() !

cr_startup_lpc17xx.c places the address of ResetISR into the second location in the Cortex-M3's vector table - which is the location the processor will start execution from as it comes out of reset.

ResetISR() then
- Copies RW data
- Creates BSS data
- Calls CMSIS SystemInit() function (if appropriate)
- Optionally calls C++ init code (not applicable in LPCXpresso which supports only C)
- Calls main() - either directly, or via Redlib C library initialisation function.

Regards,
CodeRedSupport.
0 Kudos
Reply

1,442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Tue Jun 08 01:40:19 MST 2010

Quote: CodeRedSupport
If you use the standard startup code created by the project wizard (cr_startup_lpc17.c), this contains code that will automatically copy data with initial values from flash into RAM (.data), and dynamically create zero initialised data (.bss). It does this using symbols automatically created by the linker.

Regards,
CodeRedSupport.



Ok is this, but it isn't called from main

ResetISR(void) {
    unsigned long *pulSrc, *pulDest;

    //
    // Copy the data segment initializers from flash to SRAM.
    //
    pulSrc = &_etext;
    for(pulDest = &_data; pulDest < &_edata; )
    {
        *pulDest++ = *pulSrc++;
    }
0 Kudos
Reply

1,442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Jun 08 00:03:18 MST 2010

Quote: blasiis
I need to reset all ram variable before start the application main


If you use the standard startup code created by the project wizard (cr_startup_lpc17.c), this contains code that will automatically copy data with initial values from flash into RAM (.data), and dynamically create zero initialised data (.bss). It does this using symbols automatically created by the linker.

Regards,
CodeRedSupport.
0 Kudos
Reply

1,442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Mon Jun 07 23:49:05 MST 2010

Quote: domen

You didn't say what you're trying to do.



I need to reset all ram variable before start the application main
0 Kudos
Reply

1,442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by domen on Mon Jun 07 10:12:52 MST 2010
You ran over your stack (which might contain Add, stacked registers etc.) :D
You also ran over .data section

Try this to clear only stuff below the stack:
uint32_t *Add;
Add = (uint32_t*)&Add

You didn't say what you're trying to do.
0 Kudos
Reply