Hi,
I run this code without debugger on the OM13093_LPC11C24 eval board:
// from sysctl_11xx.h
#define SYSCTL_RST_POR (1 << 0) /*!< POR reset status */
#define SYSCTL_RST_EXTRST (1 << 1) /*!< External reset status */
#define SYSCTL_RST_WDT (1 << 2) /*!< Watchdog reset status */
#define SYSCTL_RST_BOD (1 << 3) /*!< Brown-out detect reset status */
#define SYSCTL_RST_SYSRST (1 << 4) /*!< software system reset status */
uint32_t reset_source = 0;
int main()
{
reset_source = Chip_SYSCTL_GetSystemRSTStatus();
Chip_GPIO_SetPinDIROutput(LPC_GPIO, 3, 0);
Chip_GPIO_SetPinState(LPC_GPIO, 3, 0, 0);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, 3, 1);
Chip_GPIO_SetPinState(LPC_GPIO, 3, 1, 0);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, 3, 2);
Chip_GPIO_SetPinState(LPC_GPIO, 3, 2, 0);
if(reset_source & SYSCTL_RST_POR)
Chip_GPIO_SetPinState(LPC_GPIO, 3, 0, 1);
if(reset_source & SYSCTL_RST_EXTRST)
Chip_GPIO_SetPinState(LPC_GPIO, 3, 1, 1);
if(reset_source & SYSCTL_RST_SYSRST)
Chip_GPIO_SetPinState(LPC_GPIO, 3, 2, 1);
while (1)
{
if(Chip_GPIO_GetPinState(LPC_GPIO, 2, 7) == 1)
{
Chip_SYSCTL_ClearSystemRSTStatus(0x1F);
reset_source = Chip_SYSCTL_GetSystemRSTStatus();
if(reset_source & SYSCTL_RST_POR)
Chip_GPIO_SetPinState(LPC_GPIO, 3, 0, 1);
else
Chip_GPIO_SetPinState(LPC_GPIO, 3, 0, 0);
if(reset_source & SYSCTL_RST_EXTRST)
Chip_GPIO_SetPinState(LPC_GPIO, 3, 1, 1);
else
Chip_GPIO_SetPinState(LPC_GPIO, 3, 1, 0);
if(reset_source & SYSCTL_RST_SYSRST)
Chip_GPIO_SetPinState(LPC_GPIO, 3, 2, 1);
else
Chip_GPIO_SetPinState(LPC_GPIO, 3, 2, 0);
}
if(Chip_GPIO_GetPinState(LPC_GPIO, 0, 3) == 1)
{
NVIC_SystemReset();
}
}
return 0;
}
Code explanation:
pin 2_7,input - when 1 it clears SYSRSTSTAT register by caling Chip_SYSCTL_ClearSystemRSTStatus(0x1F) function
pin 0_3,input - when 1 it resets the MCU by calling NVIC_SystemReset() function
pin 3_0,output - state of the SYSCTL_RST_POR bit in SYSRSTSTAT register
pin 3_1,output - state of the SYSCTL_RST_EXTRST bit in SYSRSTSTAT register
pin 3_2,output - state of the SYSCTL_RST_SYSRST bit in SYSRSTSTAT register
Running the code above gives me these results
After powering the board up (HW MCU reset):
SYSCTL_RST_POR = 1
SYSCTL_RST_EXTRST = 1
SYSCTL_RST_SYSRST = 0
pressing a reset button on the eval board (HW MCU reset)
SYSCTL_RST_POR = 1
SYSCTL_RST_EXTRST = 1
SYSCTL_RST_SYSRST = 0
after setting pin 0_3 to 1 (SW MCU reset - NVIC_SystemReset())
SYSCTL_RST_POR = 1
SYSCTL_RST_EXTRST = 1
SYSCTL_RST_SYSRST = 1
after setting pin 2_7 to 1 (SW SYSRSTSTAT resister reset - Chip_SYSCTL_ClearSystemRSTStatus(0x1F))
SYSCTL_RST_POR = 0
SYSCTL_RST_EXTRST = 0
SYSCTL_RST_SYSRST = 0
pressing a reset button on the eval board (HW MCU reset)
SYSCTL_RST_POR = 0
SYSCTL_RST_EXTRST = 1
SYSCTL_RST_SYSRST = 0
after setting pin 0_3 to 1 (SW MCU reset - NVIC_SystemReset())
SYSCTL_RST_POR = 0
SYSCTL_RST_EXTRST = 1
SYSCTL_RST_SYSRST = 1
These results show inconsistency between the documentation and HW.
Would you try to test the code on your side please ?
Thank you !