0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

RZ/N2L SDRAM由CS2改為CS3相應(yīng)PN代碼修改方法演示

瑞薩MCU小百科 ? 來源:瑞薩嵌入式小百科 ? 2024-04-25 14:14 ? 次閱讀

瑞薩RZ/N2L MPU

RZ/N2L是一種工業(yè)以太網(wǎng)通信用MPU,可輕松將網(wǎng)絡(luò)功能添加到工業(yè)設(shè)備中。它搭載支持TSN的三端口千兆以太網(wǎng)交換機和EtherCAT從控制器,可支持EtherCAT、PROFINET RT/IRT、EtherNet/IP、OPC UA等主要的工業(yè)以太網(wǎng)通信協(xié)議。它對網(wǎng)絡(luò)專用配套芯片加以優(yōu)化,無需大幅改變設(shè)備的內(nèi)部配置即可直接連接并快速訪問外部應(yīng)用主機CPU。此外,Arm Cortex-R52的最大工作頻率為400MHz,外設(shè)功能包括帶ECC的大容量RAM與ΔΣ I/F、A/D轉(zhuǎn)換器、PWM定時器、UARTCAN等,可在單個芯片上實現(xiàn)遠程I/O、傳感器集線器、變頻器和網(wǎng)關(guān)。

39c1e05a-02c7-11ef-a297-92fbcf53809c.png

RZ/N2L PN例程,SDRAM接口片選使用的是CS2(因為RZN2L RSK 的特殊硬件設(shè)計),而根據(jù)UM,系統(tǒng)里使用單片SDRAM的話,BSC必須CS3#。本文將為您演示為了適配使用CS3的硬件要求,PN的代碼需要做的三處修改。

1

修改 hal_entry.c 文件中 bsp_sdram_init() 函數(shù),把與CS2相關(guān)的配置屏蔽掉,如下面代碼所示。

#if 0 ~ #endif 之間代碼,60~86行:

static void bsp_sdram_init (void)
{


    volatile uint32_t val;


    R_RWP_S->PRCRS  = 0x0000A50F;
    R_RWP_NS->PRCRN = 0x0000A50F;


    /* NOTE: Port setting and CKIO configuration should have been done before */


    // Configure clock frequency
    val = R_SYSC_NS->SCKCR;
    val &= ~(7<<16);
    //val |=  (6<<16);// CKIO clock: 25MHz 
    val |=  (1<<16);// CKIO clock: 66.7MHz
    R_SYSC_NS->SCKCR = val;


    /* Enable BSC and CKIO module */
    val = R_SYSC_NS->MSTPCRA;
    val &= ~(1<<0);
    R_SYSC_NS->MSTPCRA = val;
    val = R_SYSC_NS->MSTPCRA;        // dummy read: step1


    // Enable CKIO module
    val = R_SYSC_NS->MSTPCRD;
    val &= ~(1<<11);
    R_SYSC_NS->MSTPCRD = val;
    val = R_SYSC_NS->MSTPCRD;        // dummy read: step1
    
    R_RWP_NS->PRCRN = 0x0000A500;
    R_RWP_S->PRCRS  = 0x0000A500;


    /* Wait */
val = R_BSC->CSnBCR[3];        // dummy read: step2
val = R_BSC->CSnBCR[3];        // dummy read: step2
val = R_BSC->CSnBCR[3];        // dummy read: step2
val = R_BSC->CSnBCR[3];        // dummy read: step2
val = R_BSC->CSnBCR[3];        // dummy read: step2


    /* SDRAM:W9825G6KH-6 */
    /* Row address: A0-A12. Column address: A0-A8. */
val = ( 2 <<  9)// BSZ: data bus witdh: 16-bits
 | ( 1 << 11)// Reserved
 | ( 4 << 12)// TYPE: SDRAM
 | ( 0 << 16)// IWRRS: Idle State Insertion between Read-Read Cycles in the Same CS Space
 | ( 0 << 19)// IWRRD: Idle State Insertion between Read-Read Cycles in Different CS Spaces
 | ( 0 << 22)// IWRWS: Idle State Insertion between Read-Write Cycles in the Same CS Space
 | ( 0 << 25)// IWRWD: Idle State Insertion between Read-Write Cycles in Different CS Spaces
 | ( 0 << 28);// IWW: Idle Cycles between Write-Read Cycles and Write-Write Cycles
    R_BSC->CSnBCR[3] = val;


    /* Wait cycle */
val = ( 2 <<  0)// WTRC: Number of Idle states frmo REF Command/Self-refresh relase to ACTV/REF/MRS command
 | ( 2 <<  3)// TRWL: Number of Auto-precharge startup Wait Cycle
 | ( 1 <<  7)// A3CL: CAS Latency: 2
 | ( 1 << 10)// WTRCD: Number of Waits between ACTV command and READ/WRIT command
 | ( 1 << 13);// WTRP: Number of Auto-precharge completion wait states        
        R_BSC->CS3WCR_1 = val;


#if 0
    /* Wait */
val = R_BSC->CSnBCR[2];        // dummy read: step2
val = R_BSC->CSnBCR[2];        // dummy read: step2
val = R_BSC->CSnBCR[2];        // dummy read: step2
val = R_BSC->CSnBCR[2];        // dummy read: step2
val = R_BSC->CSnBCR[2];        // dummy read: step2




    /* SDRAM:W9825G6KH-6 */
    /* Row address: A0-A12. Column address: A0-A8. */
val = ( 2 <<  9)// BSZ: data bus witdh: 16-bits
 | ( 1 << 11)// Reserved
 | ( 4 << 12)// TYPE: SDRAM
 | ( 0 << 16)// IWRRS: Idle State Insertion between Read-Read Cycles in the Same CS Space
 | ( 0 << 19)// IWRRD: Idle State Insertion between Read-Read Cycles in Different CS Spaces
 | ( 0 << 22)// IWRWS: Idle State Insertion between Read-Write Cycles in the Same CS Space
 | ( 0 << 25)// IWRWD: Idle State Insertion between Read-Write Cycles in Different CS Spaces
 | ( 0 << 28);// IWW: Idle Cycles between Write-Read Cycles and Write-Write Cycles
    R_BSC->CSnBCR[2] = val;


   /* Wait cycle */
    val = ( 1 <<  7)// A3CL: CAS Latency: 2
 | ( 1 << 10);// Reserved 1
 
    R_BSC->CS2WCR_1 = val;
#endif
    /* SDRAM control */
    R_BSC->SDCR = 0x00110811;// auto-refresh, auto-precharge mode, Col 9-bits, Row 13-bits


    /* Refresh setting for SDRAM */
    R_BSC->RTCOR = BSC_PROTECT_KEY 
                 | ( 29 <<  0);        // Refresh Time: 29 counts
    R_BSC->RTCSR = BSC_PROTECT_KEY 
                 | (  0 <<  7)         // Compare match Flag: clear
                 | (  0 <<  6)         // Compare match interrupt enable: Disabled
                 | (  2 <<  3)         // Refresh timer count clock: CKIO/16
                 | (  0 <<  0);        // Refresh count: 1 time
                 
    /* wait 200us*/
    R_BSP_SoftwareDelay(200, BSP_DELAY_UNITS_MICROSECONDS);


    /* Power-on Sequence */
    /* Set mode register of SDRAM. needs wait for 2 SDRAM clock after set. */
    *((uint16_t *)0x80212040) = 0x0000;   // Burst length=1, Sequential, CL=2, Burst read and burst write
    *((uint16_t *)0x80211040) = 0x0000;   // Burst length=1, Sequential, CL=2, Burst read and burst write


}

2

pnip_reg.h 頭文件,將CS2 Region的地址定義修改為CS3的Memory Region,如下圖將0x54xxxxxx地址修改為0x58xxxxxx地址。

39f20ea6-02c7-11ef-a297-92fbcf53809c.png

#ifdef _RENESAS_RZN_
#define U_PNIP__BASE    (0x58000000 + PNIP_DEV_TOP_BASE)
#define U_PNIP__END    (0x581FFFFF + PNIP_DEV_TOP_BASE)
#define U_PERIF_AHB__BASE (0x58200000 + PNIP_DEV_TOP_BASE)
#define U_PERIF_AHB__END  (0x583FFFFF + PNIP_DEV_TOP_BASE)
#endif

3

修改Linker文件中SDRAM Adddress相關(guān)Region定義。

3a174554-02c7-11ef-a297-92fbcf53809c.png

以IAR的 fsp_xspi0_boot.icf 為例:

文件中定義了

1

RAM_Region

地址空間為:0x7440 0010 – 0x744F FFFF;

需要修改為:0x7840 0010 - 0x784F FFFF;

2

Heap_Region

地址空間為:0x5500 0000 – 0x555F FFFF;

需要修改為:0x5900 0000 – 0x595F FFFF;

3

SDRAM_NC_region

地址空間為:0x5450 0000 – 0x547F FFFF;

需要修改為:0x5850 0000 – 0x587F FFFF;


審核編輯:劉清
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 控制器
    +關(guān)注

    關(guān)注

    112

    文章

    15879

    瀏覽量

    175336
  • 以太網(wǎng)通信
    +關(guān)注

    關(guān)注

    2

    文章

    51

    瀏覽量

    10963
  • 交換機
    +關(guān)注

    關(guān)注

    20

    文章

    2571

    瀏覽量

    98229
  • AD轉(zhuǎn)換器
    +關(guān)注

    關(guān)注

    4

    文章

    249

    瀏覽量

    41287
  • EtherCAT總線
    +關(guān)注

    關(guān)注

    5

    文章

    66

    瀏覽量

    5335

原文標(biāo)題:RZ/N2L SDRAM由CS2改為CS3相應(yīng)PN代碼修改方法

文章出處:【微信號:瑞薩MCU小百科,微信公眾號:瑞薩MCU小百科】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。

收藏 人收藏

    評論

    相關(guān)推薦

    PN代碼適配客戶板子修改方法

    Renesas RZ/N2L入門套件 + 用于使用RZ/N2L MPU進行評估或開發(fā)。
    的頭像 發(fā)表于 01-10 12:20 ?1503次閱讀
    <b class='flag-5'>PN</b><b class='flag-5'>代碼</b>適配客戶板子<b class='flag-5'>修改</b><b class='flag-5'>方法</b>

    RZ/T2M RZ/N2L RZ/T2L系列應(yīng)用心得

    RZ/T2M和RZ/N2L共用各種軟件協(xié)議棧支持情況。
    的頭像 發(fā)表于 11-15 16:09 ?1626次閱讀
    <b class='flag-5'>RZ</b>/T<b class='flag-5'>2</b>M <b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> <b class='flag-5'>RZ</b>/T<b class='flag-5'>2L</b>系列應(yīng)用心得

    如何在RZ/N2L RZ/T2M的PN代碼中增加其他驅(qū)動代碼呢?

    當(dāng)前提供的PN代碼,無論是N2L平臺或T2M平臺,目前都只有IAR版本,并且不能直接調(diào)用FSP配置工具進行代碼生成(但是
    的頭像 發(fā)表于 05-20 14:18 ?765次閱讀
    如何在<b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> <b class='flag-5'>RZ</b>/T<b class='flag-5'>2</b>M的<b class='flag-5'>PN</b><b class='flag-5'>代碼</b>中增加其他驅(qū)動<b class='flag-5'>代碼</b>呢?

    Adobe GoLive cs2

    使用Adobe GoLive CS2軟件, 您可以借助直觀的可視工具充分利用CSS的功能,輕松地將現(xiàn)有Adobe資源放到Web上, 并且還能設(shè)計和發(fā)布復(fù)雜的Web和移動設(shè)備內(nèi)容。
    發(fā)表于 04-05 22:45 ?20次下載

    RZ/T2M、RZ/N2L 組硬件設(shè)計指南

    RZ/T2M、RZ/N2L 組硬件設(shè)計指南
    發(fā)表于 01-09 18:57 ?1次下載
    <b class='flag-5'>RZ</b>/T<b class='flag-5'>2</b>M、<b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> 組硬件設(shè)計指南

    RZ/N2L 組數(shù)據(jù)表

    RZ/N2L 組數(shù)據(jù)表
    發(fā)表于 01-09 19:21 ?0次下載
    <b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> 組數(shù)據(jù)表

    RZ/N2L 組用戶手冊:硬件

    RZ/N2L 組用戶手冊:硬件
    發(fā)表于 01-09 19:21 ?2次下載
    <b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> 組用戶手冊:硬件

    Renesas Starter Kit+ for RZ/N2L 快速入門指南

    Renesas Starter Kit+ for RZ/N2L 快速入門指南
    發(fā)表于 01-10 19:13 ?0次下載
    Renesas Starter Kit+ for <b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> 快速入門指南

    RZ/T2M、RZ/N2L 組硬件設(shè)計指南

    RZ/T2M、RZ/N2L 組硬件設(shè)計指南
    發(fā)表于 06-30 18:33 ?2次下載
    <b class='flag-5'>RZ</b>/T<b class='flag-5'>2</b>M、<b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> 組硬件設(shè)計指南

    RZ/N2L 組數(shù)據(jù)表

    RZ/N2L 組數(shù)據(jù)表
    發(fā)表于 06-30 19:20 ?0次下載
    <b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> 組數(shù)據(jù)表

    RZ/N2L 組用戶手冊:硬件

    RZ/N2L 組用戶手冊:硬件
    發(fā)表于 06-30 19:21 ?2次下載
    <b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> 組用戶手冊:硬件

    RZ/N2L工業(yè)網(wǎng)絡(luò)SOM套件應(yīng)用說明

    電子發(fā)燒友網(wǎng)站提供《RZ/N2L工業(yè)網(wǎng)絡(luò)SOM套件應(yīng)用說明.pdf》資料免費下載
    發(fā)表于 01-03 09:46 ?1次下載
    <b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b>工業(yè)網(wǎng)絡(luò)SOM套件應(yīng)用說明

    RZ/T2M、RZ/N2L、RZ/T2L組 硬件設(shè)計指南

    電子發(fā)燒友網(wǎng)站提供《RZ/T2M、RZ/N2L、RZ/T2L組 硬件設(shè)計指南.pdf》資料免費下
    發(fā)表于 02-02 09:39 ?2次下載
    <b class='flag-5'>RZ</b>/T<b class='flag-5'>2</b>M、<b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b>、<b class='flag-5'>RZ</b>/T<b class='flag-5'>2L</b>組 硬件設(shè)計指南

    RZ/T2M, RZ/T2L, RZ/N2L電機解決方案套件數(shù)據(jù)手冊

    電子發(fā)燒友網(wǎng)站提供《RZ/T2M, RZ/T2L, RZ/N2L電機解決方案套件數(shù)據(jù)手冊.rar
    發(fā)表于 05-13 18:12 ?5次下載
    <b class='flag-5'>RZ</b>/T<b class='flag-5'>2</b>M, <b class='flag-5'>RZ</b>/T<b class='flag-5'>2L</b>, <b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b>電機解決方案套件數(shù)據(jù)手冊

    產(chǎn)品詳解 | 瑞薩電子RZ/N2L MPU

    產(chǎn)品詳解 | 瑞薩電子RZ/N2L MPU
    的頭像 發(fā)表于 04-20 08:06 ?382次閱讀
    產(chǎn)品詳解 | 瑞薩電子<b class='flag-5'>RZ</b>/<b class='flag-5'>N2L</b> MPU