8
存儲器
8.5 外部存儲器
RA6 MCU包含用于連接到外部存儲器和器件的外部數(shù)據(jù)總線。某些產(chǎn)品還包括一個內(nèi)置的SDRAM控制器,可通過該控制器使用最高達(dá)128MB的外部SDRAM。八個可編程片選提供了許多選項,可以在每個片選上設(shè)置這些選項,以允許連接到各種外部器件。存儲器映射的外部片選區(qū)域地址從0x60000000開始。有關(guān)更多詳細(xì)信息,請參見《硬件用戶手冊》。
8.5.1 使用外部16位存儲器器件
連接具有字節(jié)選擇線的外部16位存儲器器件時,將MCU的A1連接到存儲器的A0,將MCU的A0連接到字節(jié)選擇線。
8.5.2 SDRAM初始化示例
Renesas FSP提供了采用CMSIS數(shù)據(jù)結(jié)構(gòu)的C語言頭文件,此文件映射了所有外部總線控制寄存器。以下函數(shù)是在Renesas FSP中使用CMSIS寄存器結(jié)構(gòu)初始化SDRAM存儲器控制器的示例。
左右滑動查看更多
void bsp_sdram_init (void)
{
/** Delay at least 100uS after SDCLK active */
R_BSP_SoftwareDelay(100U, BSP_DELAY_UNITS_MICROSECONDS);
/** Setting for SDRAM initialization sequence */
R_BUS->SDRAM.SDIR_b.PRC = 3U;
R_BUS->SDRAM.SSDIR_b.PRC = BSP_PRV_SDRAM_TRP - 3U;
while(R_BUS->SDRAM.SDSR)
{
/* According to h/w maual, need to confirm that all the status bits in SDSR are 0 before SDIR modification. */
}
R_BUS->SDRAM.SDIR_b.ARFC = BSP_PRV_SDRAM_SDIR_REF_TIMES;
while(R_BUS->SDRAM.SDSR)
{
/* According to h/w maual, need to confirm that all the status bits in SDSR are 0 before SDIR modification. */
}
R_BUS->SDRAM.SDIR_b.ARFI = 0U;
R_BUS->SDRAM.SDIR_b.ARFI = BSP_PRV_SDRAM_TRFC - 3U;
while(R_BUS->SDRAM.SDSR)
{
/* According to h/w maual, need to confirm that all the status bits in SDSR are 0 before SDICR modification. */
}
/** Start SDRAM initialization sequence.
* Following operation is automatically done when set SDICR.INIRQ bit.
* Perform a PRECHARGE ALL command and wait at least tRP time.
* Issue an AUTO REFRESH command and wait at least tRFC time.
* Issue an AUTO REFRESH command and wait at least tRFC time.
*/
R_BUS->SDRAM.SDICR_b.INIRQ = 1U;
while(R_BUS->SDRAM.SDSR_b.INIST)
{
/* Wait the end of initialization sequence. */
}
/** Setting for SDRAM controller */
R_BUS->SDRAM.SDCCR_b.BSIZE = BSP_PRV_SDRAM_BUS_WIDTH; /* set SDRAM bus width */
R_BUS->SDRAM.SDAMOD_b.BE = BSP_PRV_SDRAM_CONTINUOUS_ACCESSMODE; /* enable continuous access */
R_BUS->SDRAM.SDCMOD_b.EMODE = BSP_PRV_SDRAM_ENDIAN_MODE; /* set endian mode for SDRAM address space */
while(R_BUS->SDRAM.SDSR)
{
/* According to h/w maual, need to confirm that all the status bits in SDSR are 0 before SDMOD modification. */
}
/** Using LMR command, program the mode register */
R_BUS->SDRAM.SDMOD = ((((uint16_t)(BSP_PRV_SDRAM_MR_WB_SINGLE_LOC_ACC << 9)
|(uint16_t)(BSP_PRV_SDRAM_MR_OP_MODE << 7))
|(uint16_t)(BSP_PRV_SDRAM_CL << 4))
|(uint16_t)(BSP_PRV_SDRAM_MR_BT_SEQUENCTIAL << 3))
|(uint16_t)(BSP_PRV_SDRAM_MR_BURST_LENGTH << 0);
/** wait at least tMRD time */
while(R_BUS-
>SDRAM.SDSR_b.MRSST)
{
/* Wait until Mode Register setting done. */
}
/** Set timing parameters for SDRAM */
R_BUS->SDRAM.SDTR_b.RAS = BSP_PRV_SDRAM_TRAS - 1U; /* set ACTIVE-to-PRECHARGE command cycles*/
R_BUS->SDRAM.SDTR_b.RCD = BSP_PRV_SDRAM_TRCD - 1U; /* set ACTIVEto READ/WRITE delay cycles */
R_BUS->SDRAM.SDTR_b.RP = BSP_PRV_SDRAM_TRP - 1U; /* set PRECHARGE command period cycles */
R_BUS->SDRAM.SDTR_b.WR = BSP_PRV_SDRAM_TWR - 1U; /* set write recovery cycles */
R_BUS->SDRAM.SDTR_b.CL = BSP_PRV_SDRAM_CL; /* set SDRAM column latency cycles */
/** Set row address offset for target SDRAM */
R_BUS->SDRAM.SDADR_b.MXC = BSP_PRV_SDRAM_SDADR_ROW_ADDR_OFFSET - 8U;
R_BUS->SDRAM.SDRFCR_b.REFW = (uint16_t)(BSP_PRV_SDRAM_TRFC - 1U); /* set Auto-Refresh issuing cycle */
R_BUS->SDRAM.SDRFCR_b.RFC = BSP_PRV_SDRAM_REF_CMD_INTERVAL - 1U; /* set Auto-Refresh period */
/** Start Auto-refresh */
R_BUS->SDRAM.SDRFEN_b.RFEN = 1U;
/** Enable SDRAM access */
R_BUS->SDRAM.SDCCR_b.EXENB = 1U;
}
8.6 數(shù)據(jù)對齊
沒有對齊數(shù)據(jù)方面的限制。MCU能夠?qū)ζ鏀?shù)存儲地址執(zhí)行字節(jié)、字和長整型訪問。雖然對齊數(shù)據(jù)訪問仍然是最佳選擇,但并不是必須的。
8.7 字節(jié)順序限制
存儲器空間必須采用小尾數(shù)法才能在Cortex-M內(nèi)核上執(zhí)行代碼。
下一章:寄存器寫保護(hù)
-
mcu
+關(guān)注
關(guān)注
146文章
17123瀏覽量
350983 -
瑞薩
+關(guān)注
關(guān)注
35文章
22308瀏覽量
86239
原文標(biāo)題:RA6快速設(shè)計指南 [11] 存儲器 (3)
文章出處:【微信號:瑞薩MCU小百科,微信公眾號:瑞薩MCU小百科】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
發(fā)布評論請先 登錄
相關(guān)推薦
評論