LPC Link2 clearing RAM

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

LPC Link2 clearing RAM

538 Views
ironlionzion
Contributor I

volatile int __attribute__ ((section(".noinit"))) persistentVar; int bssVar; int main(void) { SystemCoreClockUpdate(); InitSysTimer(); // makes the Sleep() function work Chip_GPIO_SetPinDIR(LPC_GPIO, 2, 16, TRUE); // green LED Chip_GPIO_SetPinDIR(LPC_GPIO, 2, 17, TRUE); // red LED Chip_GPIO_SetPinDIR(LPC_GPIO, 2, 18, TRUE); // blue LED Chip_GPIO_SetPinOutHigh(LPC_GPIO, 2, 16); // green LED = off Chip_GPIO_SetPinOutHigh(LPC_GPIO, 2, 17); // green LED = off Chip_GPIO_SetPinOutHigh(LPC_GPIO, 2, 18); // green LED = off if (!(LPC_SYSCTL->SYSRSTSTAT & 0x10)) { // this IS *NOT* a software reset (NVIC_SystemReset()) // it's probably power on (or something lese) // persistentVar is garbage, initialize it to 0 persistentVar = 0; Chip_GPIO_SetPinOutLow(LPC_GPIO, 2, 16); // green LED = on } else { // this IS a software reset (NVIC_SystemReset()) // persistentVar was initialized, keep its value Chip_GPIO_SetPinOutLow(LPC_GPIO, 2, 17); // green LED = on } LPC_SYSCTL->SYSRSTSTAT |= 0x1f; // is this necessary? if (persistentVar == 0) Chip_GPIO_SetPinOutLow(LPC_GPIO, 2, 18); // green LED = on persistentVar++; bssVar++; Sleep(500000); // sleeps 0.5 milliseconds NVIC_SystemReset(); return 0; }

0 Kudos
Reply
1 Reply

434 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi John,

Could you give us more information on what you are trying to achieve? Which MCU are you using? Are you using MCUXpresso IDE?


Thanks in advance!

Best Regards,
Carlos Mendoza
Technical Support Engineer

0 Kudos
Reply