在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 51單片機(jī)資源擴(kuò)展:擴(kuò)展片外RAM

            51單片機(jī)資源擴(kuò)展:擴(kuò)展片外RAM

            作者: 時(shí)間:2016-11-19 來(lái)源:網(wǎng)絡(luò) 收藏
            51單片機(jī)資源擴(kuò)展:從片內(nèi)ROM跳轉(zhuǎn)到片外ROM 一文中擴(kuò)展了單片機(jī)程序存儲(chǔ)器,4KB存儲(chǔ)空間提升到64KB。其實(shí),4K的代碼空間還湊合,但是51自帶的256B數(shù)據(jù)存儲(chǔ)空間使用起來(lái)還真緊張,其中留給用戶的連128B都不到,所以不得不擴(kuò)展片外RAM。擴(kuò)展RAM方法和擴(kuò)展ROM差不多,都是占用P0/P2口做地址線,同時(shí)P0用鎖存器74373分時(shí)復(fù)用地址和數(shù)據(jù)信號(hào)。

            以前擴(kuò)展RAM是用匯編語(yǔ)言訪問(wèn)存儲(chǔ)器,好處是定位精準(zhǔn),指哪打哪,壞處就是:程序規(guī)模一大就有點(diǎn)難維護(hù)了,所以還得改用C實(shí)現(xiàn)。

            本文引用地址:http://www.biyoush.com/article/201611/318425.htm

            對(duì)應(yīng)于匯編語(yǔ)言用R1,R0/DPTR訪問(wèn)外部RAM,keil C擴(kuò)展了存儲(chǔ)類型,增加了如pdata(等同用movx @Rn訪問(wèn)方式)/xdata(等同于movx @DPTR訪問(wèn)方式)存儲(chǔ)類型用于訪問(wèn)片外ram。同時(shí),還提供了絕對(duì)地址訪問(wèn)的宏,如PBYTE/XBYTE,查看定義:

            #define PBYTE((unsigned char volatile pdata*)0);#define XBYTE((unsigned char volatile xdata*)0);

            其實(shí),也還是定義相應(yīng)存儲(chǔ)類型的指針~。

            上仿真圖和代碼前,整理一下keil c提供訪問(wèn)絕對(duì)地址的方法:

            1._at_定義變量:

            變量類型 [存儲(chǔ)類型] 變量名 _at_ 常數(shù),指定變量存放在常數(shù)所指定的ram位置,注意bit型變量不能使用_at_指定位置;

            2.絕對(duì)地址訪問(wèn):

            頭文件absacc.h提供了絕對(duì)地址訪問(wèn)宏,用于字節(jié)/字尋址,如

            val=XBYTE[0x0000];讀片外ram 0x00處內(nèi)存值

            XBYTE[0x0200]=val;寫片外ram 0x0200處內(nèi)存值

            擴(kuò)展ram仿真圖:

            上段去年用匯編寫的訪問(wèn)ram的代碼:

            ORG  0SJMP  STARTORG  10HSTART:;1456是要訪問(wèn)的內(nèi)存地址MOV  DPTR,#1456H;MOV  A,  #0FFH;;0xFF移入[1456]MOVX @DPTR,A;CLR  A;MOVX  A, @DPTR; ;對(duì)外部RAM 1456H讀出數(shù)據(jù)到ANOPMOV  A, #0A0H;INC  DPLMOVX @DPTR,A; ;將0xA0寫入外部RAM 1457HNOP;從外部RAM [1457]H讀出數(shù)據(jù)到AMOVX  A, @DPTR; NOPSJMP STARTEND
            c語(yǔ)言版本:

            #include #include #define OFFRAMBASE 0x100unsigned char xdata offRamVal0 _at_ OFFRAMBASE*2;unsigned char xdata offRamVal1 _at_ 0x00;int main(){unsigned char idata index = 0;offRamVal0 = 0xAA;offRamVal1 = 0xCC;for(index=0;index<0x10;index++){XBYTE[index+OFFRAMBASE] = 0x55;	}		return 0;}
            最后看下程序運(yùn)行后6264內(nèi)部存儲(chǔ)的數(shù)據(jù):
            0000: CC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................0100: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 | UUUUUUUUUUUUUUUU0110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................0120: 00 00 00 00 00 00 00 00 00 00 0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................01F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................0200: AA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................


            評(píng)論


            技術(shù)專區(qū)

            關(guān)閉