AnsweredAssumed Answered

LPC Link2 clearing RAM

Question asked by Tomáš Nechutný on Sep 15, 2017
Latest reply on Sep 18, 2017 by Carlos_Mendoza

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; }

Outcomes