How can I define variable in S32K146 RAM_U

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How can I define variable in S32K146 RAM_U

1,755 次查看
Willian_Wu
Contributor I

Hi everyone,

when i define a array more than 64KB (or two with 32KB),

the compiler said m_data_2 overflowed.

but In S32K146 ,there are RAM_L(64KB) and RAM_U(64KB) , totally 128KB  ,  so  How can I define variable in S32K146 RAM_U?

 

thanks a lot

0 项奖励
回复
5 回复数

1,747 次查看
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Willian,

 

At first, I would like to mention that SRAM_U has a size of 60 KB. That is why you have had difficulties with placing two 32 KB arrays into the m_data_2 section.

You can refer to RM rev 12.1

dianabatrlova_0-1600778998878.png

There are two regions:

  • SRAM_L from 1FFF_0000h to 1FFF_FFFFh 
  • SRAM_U from 2000_0000h to 2000_EFFFh

There is an important note:

"Misaligned accesses across the 2000_0000h boundary are not
supported in the Arm Cortex-M4F architecture"

So, that is why it is easier to have two RAM segments in the linker file.

Also, I suggest you to look at the linker file of the project to see what else is placed in the m_data/ m_data_2 sections (heap, stack).

 

Best regards,

Diana

0 项奖励
回复

1,739 次查看
Ahmad_bozorgi
Contributor II

Hi @dianabatrlova 

 

what is benefit of 2 segment in SRAM and specially SRAM_L ?

0 项奖励
回复

1,728 次查看
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Ahmad,

 

At first, I would like to suggest looking at RM rev 12.1 section 33.2.1. Each region uses a different bus:

dianabatrlova_0-1600856506524.png

When you look at the linker file of some project, you can see that SRAM_L (m_data) includes the code_ram section, global variables, vector table. SRAM_U (m_data_2) contains stack and heap. 

The benefit of this approach is described in the AN below in the section "3.1 SRAM accesses"

https://www.nxp.com/docs/en/application-note/AN4745.pdf

"The dual SRAM blocks allow the SRAM controller to handle simultaneous accesses to the SRAMs as long as
those accesses are not to the same SRAM block. Allowable simultaneous accesses to the SRAM are:
• Core CODE (SRAM_L) and core system (SRAM_U) accesses
• Core CODE (SRAM_L) and non-core master to SRAM_U
• Core system (SRAM_U) and non-core master to SRAM_L

Strategic placement of code and data into each of the SRAM blocks can help to increase parallelism and overall performance.
For a typical application, placing critical code in the SRAM_L block and placing data and the stack into the SRAM_U block
will yield the best performance."

Best regards,

Diana

1,723 次查看
Ahmad_bozorgi
Contributor II

thanks for your kind reply.

 

what is main difference between CODE BUS & SYSTEM BUS? (both of them come from CPU?)

and what can be "critical code" ? 

0 项奖励
回复

1,687 次查看
dianabatrlova
NXP TechSupport
NXP TechSupport