We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I wanted to know is there away to simulate data abort handler in cortex M4, I wanted to run some bin images from third party libraries, so I wanted to capture the data access to certain memory areas and replace the required answers to them to some custom error data that I want.
I have managed to trap the memfault, but if I try to use it more than once, the next time I access the violaing memory, it would generate hardfault!!!
See the code
#include "LPC43xx.h" // Device header int i=0; int main(void) { static int test; MPU->RNR = 0;//indicate MPU region 0 MPU->RBAR = 0x00000000; // update the base address for the region 0 MPU->RASR = 0x0307003F; test = MPU->RASR; MPU->RNR = 6; MPU->RBAR = 0x20080000; // update the base address for the region 6 MPU->RASR = 0x0007001B; i = MPU->RASR; SCB->SHCSR |=(1<<16); //Enable Memory management fault MPU->CTRL |= 1;//enable MPU for(i=0;i<10;i++) { test = (*(unsigned int *)0x20080000); } while(1) { i++; } } __asm void __setPsp(); int value; void HardFault_Handler (void) { int r1; value=r1; __setPsp(); } __asm void __setPsp() { add r13,32 ldr r14,[r13] add r14,#2 mov r0,#0 MSR IPSR,r0 mov r15,r14 } void MemManage_Handler(void) { __setPsp(); }
Isn't it suppose to generate memfault again?