Hello,
I'm using LPC1788 in my project and I need to execute some code from SDRAM at address 0xA0000000, but there is one issue. The issue is that MPU considers this address a non executable memory space.
What I need is to how to set MPU registers to make the SDRAM as a executable memory space.
I could not understand how to do this by user manual, it is very confusing because the information is not clear enough.
Does anyone knows how to setting it?
Thankyou!
Henrique
A found it at this link :
forums.nxp.com/viewtopic.php
This is the code I use to program a specific MPU region:
static void mpu_region_setup(uint32_t a_addr, uint32_t a_region, uint32_t a_size, uint32_t a_ap, uint32_t a_mem_attrib, uint32_t a_srd, uint32_t a_XN, uint32_t a_enable) { // Setup procedure for each region MPU->RBAR = (a_addr & 0xFFFFFFE0) | (a_region & 0xF) | 0x10 ; MPU->RASR = ((a_XN & 0x1)<<28) | ((a_ap & 0x7)<<24) | ((a_mem_attrib & 0x3F)<<16) | ((a_srd&0xFF)<<8) | ((a_size & 0x1F)<<1)| (a_enable & 0x1) ; }
Usage:
// memory pool size must be a power of 2 // memory pool address must be a multiple of the size void user_tasks_enable_ddc_access(void) { portBASE_TYPE xRunningPrivileged = portRaisePrivilege() ; // MPU->CTRL = 0 ; // Disable MPU first mpu_region_setup( (uint32_t)&umm_heap, 7, // always reprogramming MPU region 7 e_mpu_region_size_4_mega_byte, 3, // full access 0, // strongly ordered, shareable 0, // subregion disabled 0, // don't allow instruction execution 1) ; // region enabled // MPU->CTRL = 1 ; // Enable MPU portRESET_PRIVILEGE( xRunningPrivileged ) ; }