This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

cortex-m23 fault after enable MPU

void test_mpu(){
	 ARM_MPU_SetMemAttr(0UL, ARM_MPU_ATTR(       /* Normal memory */
    ARM_MPU_ATTR_MEMORY_(0UL, 1UL, 1UL, 1UL), /* Outer Write-Back transient with read and write allocate */
    ARM_MPU_ATTR_MEMORY_(0UL, 0UL, 1UL, 1UL)  /* Inner Write-Through transient with read and write allocate */
  ));
  
  ARM_MPU_SetRegion(0UL,
    ARM_MPU_RBAR(0x20000000UL, ARM_MPU_SH_NON, 0UL, 1UL, 1UL),  /* Non-shareable, read/write, non-privileged, execute-never */
    ARM_MPU_RLAR(0x20000FFFUL, 0UL)                             /* 1MB memory block using Attr 0 */
  );
  
  ARM_MPU_Enable(4);
  
  // Execute application code that is access protected by the MPU
  
  ARM_MPU_Disable();
}

I'm trying to use the MPU on cortex-m23.I want to set the ram address from 0x20000000 to 0x20001000 to XN.

After the instruction execute after the ARM_MPU_Enable, any instructions after it will result in a hardfault.I have set the background attribute and it does not work.

Can anyone help me?