1 Introduction
Configurable continuous SRAM address is a new and beneficial feature on the MCXA series. Continuous SRAM address offers the following benefits:
- Convenient for DMA operation leveraging the continuous SRAM address mapping.
- Suitable for applications that require a large continuous SRAM region, such as graphic display.
This application note considers MCXA156 as an example to demonstrate how to configure and use a continuous SRAM address.
2 Memory map and architecture
This section describes the memory map and memory architecture of MCXA156.
2.1 Memory map
Table 1 shows the memory map of MCXA156, which can also be found in the attachment of the Reference Manual. The address of SRAM X0 Alias follows the end of SRAM B2, offering a continuous address space with SRAM A0, A1, A2, A3, B0, B1, and B2. As a result, there are a total of 128 KB SRAMs with continuous address.
Start address (hex) | End address (hex) | Size (KB) | Description |
---|---|---|---|
04000000 | 04001FFF | 8 | SRAM X0 (Slave Port 0) |
04002000 | 04002FFF | 4 | SRAM X1 (Slave Port 0) |
20000000 | 20001FFF | 8 | SRAM A0 (Slave Port 1) |
20002000 | 20005FFF | 16 | SRAM A1 (Slave Port 1) |
20006000 | 20007FFF | 8 | SRAM A2 (Slave Port 1) |
20008000 | 2000FFFF | 32 | SRAM A3 (Slave Port 1) |
20010000 | 20017FFF | 32 | SRAM B0 (Slave Port 3) |
20018000 | 2001BFFF | 16 | SRAM B1 (Slave Port 3) |
2001C000 | 2001DFFF | 8 | SRAM B2 (Slave Port 3) |
2001E000 | 2001FFFF | 8 | SRAM X0 Alias |
Note: The SRAM X0 Alias region is reserved by default.
2.2 Memory architecture
Figure 1 shows the memory architecture of MCXA156. To access the SRAM X0 Alias region address, enable the corresponding CPU0_SBUS, DMA0, and USB0 bits of the AHB matrix remap control (remap) register in the SYSCON module. As a result, the CM33 System Bus, DMA, and USB FS can access up to 128 KB continuous address. After enabling the bits of remap, both SRAM X0 (0x04000000-0x04001FFF) and SRAM X0 Alias (0x2001E000-0x2001FFFF) region can be accessed. When the SRAM X0 Alias address is accessed, the address gets translated to the corresponding SRAM X0 address. Then the user can access the SRAM X0.
Figure 1. Memory architecture: A block diagram illustrating the memory architecture of the MCXA156. It shows connections between the CM33 core, DMA, USB FS, and the Multi-layer AHB matrix to various memory blocks including ROM, Flash, SRAM X0, SRAM X1, SRAM A0-A3, SRAM B0-B2, and SRAM X0 Alias. A legend indicates which components can access these blocks directly and which require remap bits to be enabled. The diagram specifically notes that CM33 accesses SRAM X0 Alias via the System Bus and SRAM X0 via the Code Bus.
3 SRAM X0 Alias usage limitations
This section lists the limitations on SRAM X0 Alias usage as follows:
- Enable the corresponding remap bit before accessing the SRAM X0 Alias region.
- Consider the value of the stack pointer (SP). The user usually wants to define a continuous SRAM address in the linker file and allocate the stack region at the end of the SRAM. The stack pointer is 32-bit and the stack region must be 32-bit aligned, so the initial stack pointer address is usually the defined SRAM end address plus one.
If the user wants to use the SRAM X0 Alias region, the initial stack pointer has to be 0x20020000. The ROM checks the stack pointer before jumping to the extended bootloader. For the MCXA156 extended bootloader, the valid stack pointer region is 0x20000000 to 0x2001FFFF and 0x04000000 to 0x04002FFF, so 0x20020000 is an invalid address. This is the stack pointer limitation of SRAM X0 Alias usage.
4 Workarounds
This section describes the two workarounds to configure continuous SRAM address.
4.1 Workaround to allocate the STACK space to form continuous SRAM address
To allocate the STACK space at the end of a valid stack pointer region and enable remap bits, perform the following steps:
- Set the initial stack pointer to 0x2001FFFC, which is a valid stack pointer address for ROM validation and is 32-bit aligned.
- The SRAM space from 0x2001FFFD to 0x2001FFFF can be used for data to check the safety of a stack pointer.
- Then, enable the corresponding remap bit before using the stack.
4.2 Workaround to cheat the ROM to validate the SP value successfully to form a continuous SRAM address
To cheat the ROM and form a continuous SRAM address, perform the following steps:
- Set the first word of the vector table to a valid stack pointer value.
- Then, enable the corresponding remap bit.
- Set the SP register to the desired value before using the stack.
Note: The SP value in the vector table is only for ROM checking, not for the real SP value. Therefore, take care when using the SP value in the vector table in the application code.
The following sections describe the detailed steps of this workaround for different IDEs. To modify the project code to implement the continuous SRAM address in the MCUXpresso IDE, perform the following steps: Figure 2. SRAM settings in MCUXpresso IDE: A screenshot of the MCUXpresso IDE showing the memory configuration settings for the MCXA156. It details the memory regions like Flash, SRAM, and SRAMX, along with their addresses and sizes, indicating how to adjust them to include the SRAM X0 Alias region. Figure 3. Set the first word of the vector table in startup_mcxa156.c: A C code snippet showing the definition of the vector table in Figure 4. Enable remap and configure the SP register in startup_mcxa156.c: A C code snippet demonstrating the To modify the project code to implement the continuous SRAM address in IAR IDE, perform the following steps: Figure 5. SRAM settings in linker file: A C preprocessor directive snippet showing how to define symbols and memory regions in a linker script for IAR IDE, specifically adjusting Figure 6. Set the first word of the vector table in startup_MCXA156.s: An assembly code snippet for Figure 7. Enable remap and configure SP register in startup_MCXA156.s: An assembly code snippet for To modify the project code to implement the continuous SRAM address in the Keil IDE, perform the following steps: Figure 8. SRAM settings in linker file: A C preprocessor directive snippet showing how to define symbols in a linker file for Keil IDE, specifically adjusting Figure 9. Set the first word of the vector table in startup_MCXA156.S: An assembly code snippet for Figure 10. Enable Remap and configure SP register in startup_MCXA156.S: An assembly code snippet for 4.2.1 MCUXpresso IDE
startup_mcxa156.c
. It highlights the _vStackBase
which serves as the initial stack pointer for ROM validation.ResetISR
function. It shows assembly instructions to enable the remap bit (writing to 0xE000ED08
and 0x40091200
) and configure the Stack Pointer (MSP) and MSPLIM registers with the correct stack region values.4.2.2 IAR IDE
m_data_end
to include the SRAM X0 Alias region. Also, modify the DATA_region
to reserve the SRAM X0 region to ensure data security, as shown in Figure 5.m_data_end
and DATA_region
to accommodate the SRAM X0 Alias.startup_MCXA156.s
showing the vector table, where the first entry (DCD sfb(CSTACK)
) points to the initial stack pointer for ROM validation.startup_MCXA156.s
demonstrating the Reset_Handler
. It includes instructions to mask interrupts, configure the Vector Table Offset Register (VTOR) and MSPLIM, enable remap by writing to 0xE000ED08
and 0x40091200
, and set the Stack Pointer (MSP) to the desired value.4.2.3 Keil IDE
m_data_size
to include the SRAM X0 Alias region, as shown in Figure 8.m_data_size
to include the SRAM X0 Alias region.startup_MCXA156.S
showing the vector table, where the first entry (.long Image$$ARM LIB STACK$$ZI$$Base
) points to the initial stack pointer for ROM validation.startup_MCXA156.S
demonstrating the Reset_Handler
. It shows instructions to mask interrupts, configure VTOR and MSPLIM, enable remap by writing to 0xE000ED08
and 0x40091200
, and set the Stack Pointer (MSP) to the actual stack region value.
5 Demo validation
This section provides a demo for validating SP register, read and write for boundary unaligned address, and DMA access to continuous SRAM address. Table 2 describes the hardware and software requirements. To set up this demo, perform the following steps: The first word in the vector table, the initial stack pointer, has a value of 0x2001f000, which is a valid value for ROM, as shown in Figure 11. Figure 11. Initial stack pointer value: A screenshot from a debugger showing register values. It highlights the The corresponding remap bits are enabled, and the value of the SP register is the end address of SRAM X0 Alias plus one, as shown in Figure 12. The above operation is completed before using the stack. Figure 12. Enable remap and configure the SP register: A screenshot from a debugger showing register values. It highlights the SYSCON remap register (e.g., Figure 13 shows the read and write test for boundary unaligned address as follows: The 32-bit *p_test address is not 4 bytes aligned and spans SRAM B2 and SRAM X0 Alias, the read and write works fine. Figure 13. Access to boundary unaligned address: A text output showing the results of a read/write test. It indicates that a 32-bit test point address This demo also tests the DMA access to this continuous SRAM address in Active and Low power mode, and it works fine. The destination buffer spans between RAM B2 and RAM X0 Alias, and DMA can transport normally as shown from the log information in Figure 14. In Power Down mode, the SYSCON register is in retention state, and can still use DMA partial wakeup to transport data on continuous SRAM address. Figure 14. DMA access to continuous SRAM address: A text output showing the results of a DMA access test in both Active and Power Down modes. It displays source and destination buffer addresses and data, confirming successful data transfer to and from the continuous SRAM address range, including during power-down states using DMA partial wakeup. Figure 15 shows that the MCU is in Power Down mode and uses DMA partial wakeup to transport data on continuous SRAM address. Figure 15. Power consumption measurement: A graph showing power consumption over time. It illustrates periods of "Power Down" and "DMA partial wakeup," with summary values for current consumption.5.1 Hardware and software requirements
Category Description Hardware Software IDEs supported: 5.2 Set up
5.3 SP register validation
sp
(Stack Pointer) register with the value 0x2001f000
, which is a valid value for ROM validation.CPU0_SBUS
, DMA0
, USB0
bits enabled) and the sp
(Stack Pointer) register with the value 0x20020000
, which is the end address of SRAM X0 Alias plus one.5.4 Read and write test for boundary unaligned address
0x2001DFFF
(last byte of SRAM B2) was written with 0xFFFFFFFF
, and the updated value read back was 0xffffffff
, demonstrating that unaligned access across SRAM B2 and SRAM X0 Alias works correctly.5.5 DMA access to continuous SRAM address test
6 Summary
This application note introduces how to configure and use the SRAM X0 Alias to form a continuous SRAM address, and provides a demo to validate the feasibility of continuous SRAM address.
7 Note about the source code in the document
Example code shown in this document has the following copyright and BSD-3-Clause license:
Copyright 2024 NXP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials must be provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 Revision history
Table 3 summarizes the revisions to this document.
Document ID | Release date | Description |
---|---|---|
AN14377 v.1 | 26 July 2024 | Initial public release |
Legal information
Definitions
Draft - A draft status on a document indicates that the content is still under internal review and subject to formal approval, which may result in modifications or additions. NXP Semiconductors does not give any representations or warranties as to the accuracy or completeness of information included in a draft version of a document and shall have no liability for the consequences of use of such information.
Disclaimers
Limited warranty and liability - Information in this document is believed to be accurate and reliable. However, NXP Semiconductors does not give any representations or warranties, expressed or implied, as to the accuracy or completeness of such information and shall have no liability for the consequences of use of such information. NXP Semiconductors takes no responsibility for the content in this document if provided by an information source outside of NXP Semiconductors. In no event shall NXP Semiconductors be liable for any indirect, incidental, punitive, special or consequential damages (including - without limitation - lost profits, lost savings, business interruption, costs related to the removal or replacement of any products or rework charges) whether or not such damages are based on tort (including negligence), warranty, breach of contract or any other legal theory. Notwithstanding any damages that customer might incur for any reason whatsoever, NXP Semiconductors' aggregate and cumulative liability towards customer for the products described herein shall be limited in accordance with the Terms and conditions of commercial sale of NXP Semiconductors.
Right to make changes - NXP Semiconductors reserves the right to make changes to information published in this document, including without limitation specifications and product descriptions, at any time and without notice. This document supersedes and replaces all information supplied prior to the publication hereof.
Suitability for use - NXP Semiconductors products are not designed, authorized or warranted to be suitable for use in life support, life-critical or safety-critical systems or equipment, nor in applications where failure or malfunction of an NXP Semiconductors product can reasonably be expected to result in personal injury, death or severe property or environmental damage. NXP Semiconductors and its suppliers accept no liability for inclusion and/or use of NXP Semiconductors products in such equipment or applications and therefore such inclusion and/or use is at the customer's own risk.
Applications - Applications that are described herein for any of these products are for illustrative purposes only. NXP Semiconductors makes no representation or warranty that such applications will be suitable for the specified use without further testing or modification. Customers are responsible for the design and operation of their applications and products using NXP Semiconductors products, and NXP Semiconductors accepts no liability for any assistance with applications or customer product design. It is customer's sole responsibility to determine whether the NXP Semiconductors product is suitable and fit for the customer's applications and products planned, as well as for the planned application and use of customer's third party customer(s). Customers should provide appropriate design and operating safeguards to minimize the risks associated with their applications and products. NXP Semiconductors does not accept any liability related to any default, damage, costs or problem which is based on any weakness or default in the customer's applications or products, or the application or use by customer's third party customer(s). Customer is responsible for doing all necessary testing for the customer's applications and products using NXP Semiconductors products in order to avoid a default of the applications and the products or of the application or use by customer's third party customer(s). NXP does not accept any liability in this respect.
Terms and conditions of commercial sale
NXP Semiconductors products are sold subject to the general terms and conditions of commercial sale, as published at https://www.nxp.com/profile/terms, unless otherwise agreed in a valid written individual agreement. In case an individual agreement is concluded only the terms and conditions of the respective agreement shall apply. NXP Semiconductors hereby expressly objects to applying the customer's general terms and conditions with regard to the purchase of NXP Semiconductors products by customer.
Export control
This document as well as the item(s) described herein may be subject to export control regulations. Export might require a prior authorization from competent authorities.
Suitability for use in non-automotive qualified products
Unless this document expressly states that this specific NXP Semiconductors product is automotive qualified, the product is not suitable for automotive use. It is neither qualified nor tested in accordance with automotive testing or application requirements. NXP Semiconductors accepts no liability for inclusion and/or use of non-automotive qualified products in automotive equipment or applications. In the event that customer uses the product for design-in and use in automotive applications to automotive specifications and standards, customer (a) shall use the product without NXP Semiconductors' warranty of the product for such automotive applications, use and specifications, and (b) whenever customer uses the product for automotive applications beyond NXP Semiconductors' specifications such use shall be solely at customer's own risk, and (c) customer fully indemnifies NXP Semiconductors for any liability, damages or failed product claims resulting from customer design and use of the product for automotive applications beyond NXP Semiconductors' standard warranty and NXP Semiconductors' product specifications.
HTML publications
An HTML version, if available, of this document is provided as a courtesy. Definitive information is contained in the applicable document in PDF format. If there is a discrepancy between the HTML document and the PDF document, the PDF document has priority.
Translations
A non-English (translated) version of a document, including the legal information in that document, is for reference only. The English version shall prevail in case of any discrepancy between the translated and English versions.
Security
Customer understands that all NXP products may be subject to unidentified vulnerabilities or may support established security standards or specifications with known limitations. Customer is responsible for the design and operation of its applications and products throughout their lifecycles to reduce the effect of these vulnerabilities on customer's applications and products. Customer's responsibility also extends to other open and/or proprietary technologies supported by NXP products for use in customer's applications. NXP accepts no liability for any vulnerability. Customer should regularly check security updates from NXP and follow up appropriately. Customer shall select products with security features that best meet rules, regulations, and standards of the intended application and make the ultimate design decisions regarding its products and is solely responsible for compliance with all legal, regulatory, and security related requirements concerning its products, regardless of any information or support that may be provided by NXP. NXP has a Product Security Incident Response Team (PSIRT) (reachable at PSIRT@nxp.com) that manages the investigation, reporting, and solution release to security vulnerabilities of NXP products.
NXP B.V.
NXP B.V. is not an operating company and it does not distribute or sell products.
Trademarks
Notice: All referenced brands, product names, service names, and trademarks are the property of their respective owners.
NXP - wordmark and logo are trademarks of NXP B.V.
AMBA, Arm, Arm7, Arm7TDMI, Arm9, Arm11, Artisan, big.LITTLE, Cordio, CoreLink, CoreSight, Cortex, DesignStart, DynamIQ, Jazelle, Keil, Mali, Mbed, Mbed Enabled, NEON, POP, RealView, SecurCore, Socrates, Thumb, TrustZone, ULINK, ULINK2, ULINK-ME, ULINKPLUS, ULINKpro, µVision, Versatile - are trademarks and/or registered trademarks of Arm Limited (or its subsidiaries or affiliates) in the US and/or elsewhere. The related technology may be protected by any or all of patents, copyrights, designs and trade secrets. All rights reserved.
IAR - is a trademark of IAR Systems AB.