/* * fault_test.c * * Created on: 2016/12/25 * Author: Armink */ #include #include "mcu.h" #include #include "Mcu_Drvw.h" void fault_test_by_unalign(void) { volatile int * SCB_CCR = (volatile int *) 0xE000ED14; // SCB->CCR volatile int * p; volatile int value; *SCB_CCR |= (1 << 3); /* bit3: UNALIGN_TRP. */ p = (int *) 0x00; value = *p; printf("addr:0x%02X value:0x%08X\r\n", (int) p, value); p = (int *) 0x04; value = *p; printf("addr:0x%02X value:0x%08X\r\n", (int) p, value); p = (int *) 0x03; value = *p; printf("addr:0x%02X value:0x%08X\r\n", (int) p, value); } void fault_test_by_div0(void) { volatile int * SCB_CCR = (volatile int *) 0xE000ED14; // SCB->CCR int x, y, z; *SCB_CCR |= (1 << 4); /* bit4: DIV_0_TRP. */ x = 10; y = 0; z = x / y; printf("z:%d\n", z); } char*strReason[] = { "WAKEUP_RESET = 0U ", "LVD_RESET = 1U ", "LOC_RESET = 2U ", " ", " ", "WATCHDOG_RESET ", "PIN_RESET = 6U ", "POWER_ON_RESET ", " ", "LOCKUP_RESET = 9U ", "SW_RESET = 10U ", "MDM_AP_RESET ", "SERU_COLD_RESET ", "SERU_SYS_RESET ", " ", "SERU_SACKERR ", "MULTIPLE_RESET_REASON " }; void ShowResetReason(void) { Mcu_Drvw_ResetType Reason = Mcu_Drvw_GetResetReason(); printf("RsetReson = %s \t 0x%08x \r\n", strReason[Reason],Reason); }