2383549_zh-CN

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

2383549_zh-CN

2383549_zh-CN

i.MXRT1176:关于访问外部SRAM的问题

你好,

我无法访问外部SRAM。通过 CSX1(Pad L14 – GPIO_AD_26)选择 SRAM,我的测试程序总是触发信号 MemoryManage Fault。我的代码哪里出错了?提前感谢您的帮助。

/*

* 版权所有 2017 NXP

* ALL RIGHTS RESERVED.

*

* SPDX 许可证标识符:BSD-3-Clause

*/

#include "board.h"

#include "fsl_debug_console.h"

#include "fsl_device_registers.h"

#include "pin_mux.h"

#include "fsl_semc.h"

#include "clock_config.h"

/*******************************************************************************

* 定义

******************************************************************************/

#define EXAMPLE_SEMC SEMC

#define EXAMPLE_SEMC_CLK_FREQ CLOCK_GetRootClockFreq(kCLOCK_Root_Semc)


/*******************************************************************************

* 原型

******************************************************************************/

extern status_t BOARD_InitSRAM ( void ) ;


/*******************************************************************************

* 变量

******************************************************************************/


/*******************************************************************************

* 代码

******************************************************************************/

#define SRAM_BASE 0x60000000

//#define SRAM_BASE 0x81000000

status_t BOARD_InitAsyncSRAM_CS1 ( void )

{

semc_config_t config ;

semc_sram_config_t xsram_config ;


uint32_t clockFrq = kCLOCK_Root_Semc ;


SEMC_GetDefaultConfig ( & config ) ;

config.dqsMode = kSEMC_Loopbackdqspad ;​​

SEMC_Init ( SEMC , &配置) ;


memset ( & config , 0 , sizeof ( semc_config_t )) ;

memset ( & xsram_config , 0 , sizeof ( semc_sram_config_t )) ;



xsram_config.address = 0x60000000 ;​​

xsram_config.memsize_kbytes​​= 512 ;

xsram_config.addrPortWidth​​= 16 ;

xsram_config 。端口大小= kSEMC_PortSize16Bit ;

xsram_config.addrMode = kSEMC_AddrDataNonMux ;​​

xsram_config.syncMode = kSEMC_AsyncMode ;​​

xsram_config.advActivePolarity​​= kSEMC_AdvActiveLow ;

xsram_config.advLevelCtrl​​= kSEMC_AdvLow ;

xsram_config.burstLen = kSEMC_Nor_BurstLen1 ;​​


xsram_config.tWeLow_Ns​​= 25 ;

xsram_config.tWeHigh_Ns​​= 25 ;

xsram_config.tReLow_Ns​​= 25 ;

xsram_config.tReHigh_Ns​​= 25 ;

xsram_config.tTurnAround_Ns​​= 10 ;

xsram_config.cePinMux = kSEMC_MUXCSX1 ;​​

xsram_config.waitEnable = true ;​​

xsram_config.waitSample = true ;​​


xsram_config . tCeSetup_Ns= 25 ;

xsram_config.tCeHold_Ns​​= 20 ;

xsram_config.tAddrSetup_Ns​​= 25 ;

xsram_config.tAddrHold_Ns​​= 25 ;

xsram_config.tWriteSetup_Ns​​= 25 ;

xsram_config.tWriteHold_Ns​​= 25 ;

xsram_config.readCycle = 30 ;​​

xsram_config.readHoldTime_Ns​​= 25 ;


xsram_config.tCeInterval_Ns​​= 25 ;

xsram_config.tAddr2WriteHold_Ns​​= 25 ;

xsram_config.latencyCount​​= 3 ;

xsram_config.delayChain = 25 ;​​

xsram_config.addr27 = kSEMC_MORA27_NONE ;​​



SEMC -> IOCR |= 0x00908BB6 ;

// SEMC->IOCR |= 0x08;

return SEMC_ConfigureSRAMWithChipSelection ( SEMC , kSEMC_SRAM_CS1 , & xsram_config , clockFrq ) ;

}



/*!

* @brief 主函数

*/

int main ( void )

{

/* 硬件初始化。*/

BOARD_ConfigMPU () ;

BOARD_InitPins () ;

BOARD_BootClockRUN () ;

BOARD_InitDebugConsole () ;


BOARD_InitAsyncSRAM_CS1 () ;


SEMC -> IOCR |= SEMC_IOCR_MUX_CSX1 ( 0x08 ) ;

PRINTF ( "\r\n启动 SEMC SRAM MSpec,执行 WAIT 写入测试。\r\n" ) ;

PRINTF ( "CCM_OBS_SEMC_CLK_ROOT:%d\r\n" , CLOCK_GetFreqFromObs ( CCM_OBS_SEMC_CLK_ROOT )) ;



//////////////////////////////////////////////////////////////////////////////////////////////

volatile uint16_t * sram_ptr = ( volatile uint16_t * ) 0x60000000 ;


uint16_t i = 0 ;

* sram_ptr = 0 ;


for ( i = 0 ; i <= 10 ; i ++ )

{

* sram_ptr = i ;

}


for ( i = 0 ; i <= 10 ; i ++ )

{

PRINTF ( "\r\n sram = %d \r\n" , sram_ptr ) ;

}

}

Re: i.MXRT1176: Question about accessing an external SRAM

嗨@RainerHL ,

非常感谢您对我们产品的关注以及对我们社区的使用。

1:您的代码在 CSX1/CS1 上配置了 SEMC SRAM,但测试访问了 0x60000000,这不是 i.MX RT1170 的有效 SEMC SRAM 映射。这是导致内存管理故障的主要原因。

mayliu1_1-1782110430487.png

请使用与配置的 CSX1 设备对应的 SEMC SRAM 基地址窗口,而不是 0x60000000。

2:您的手动 IOCR 写入。参考手册指出,IOCR 配置应该是静态的;不支持动态重映射。

mayliu1_0-1782110416135.png

mayliu1_2-1782110479824.png


3:请检查项目中的 MPU 配置。

4:PRINTF("\r\n sram = %d \r\n", sram_ptr);

这将打印指针值,而不是 SRAM 数据。它应该对指针(例如 *sram_ptr)进行解引用,但这并不是 MemoryManage 故障的原因。


希望对你有帮助

顺祝商祺!

5月

タグ(1)
評価なし
バージョン履歴
最終更新日:
‎06-23-2026 02:34 AM
更新者: