diff --git a/mpu_user_console_etu.c b/mpu_user_console_etu.c index 123bfe75753602ce9411c9f42ce9d674fe1cef11..bfcefbb96038507a5cf342118aee1ecf181bf6f3 100644 --- a/mpu_user_console_etu.c +++ b/mpu_user_console_etu.c @@ -22,16 +22,28 @@ #include "uart.h" #include "macro.h" +#define BUF_SIZE 100 + #define MMFAR *(unsigned *)0xE000ED34 unsigned user_stack[USER_STACK_SIZE]; // space for user stack void *user_stating_address; int *p_sram2 = (int*) 0x2007c000, a, *p_out_of_mem = (int*) 0x80000; +unsigned arr_addr[BUF_SIZE] = {0}; +unsigned arr_err_code[BUF_SIZE] = {0}; +volatile static unsigned idx_error; + void switch_to_user_mode(); void asm_test_fault(); void MemManage_Handler() { + arr_addr[idx_error] = MMFAR; + arr_err_code[idx_error] = SCB->CFSR; + idx_error++; + + SCB->CFSR = 0xFFFF; + LPC_GPIO2->FIOPIN = idx_error; } void test_supervisor_mode() { @@ -56,6 +68,8 @@ void test_user_mode() { int main(void) { + LPC_GPIO2->FIODIR = 0xFF; + LPC_GPIO2->FIOPIN = 0; // MPU configuration here... // Region 0 (Flash) MPU->RNR = 0;