亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? c518.txt

?? dsp&c51的編程,從小百合上down的
?? TXT
?? 第 1 頁 / 共 2 頁
字號:
發(fā)信人: reflection (似水流年), 信區(qū): EEtechnology 

標(biāo)  題: C51 Primer (7) Accessing External Memory mapped 

發(fā)信站: 南京大學(xué)小百合站 (Wed Nov 24 12:00:35 1999), 轉(zhuǎn)信 

  

  

7 Accessing External Memory Mapped 

Peripherals 

Commonly, extra IO ports are added to 8051s to compensate for the loss of Po 

rts 0 and 2. This is normally done by making the additional device(s) appear 

 to be just external RAM bytes. Thus they are addressed by the MOVX A,@DPTR 

instruction. Typically UARTS, additional ports and real time clock devices a 

re added to 8031s as xdata-mapped devices. 

The simplest approach to adding external devices is to attach the /RD and or 

 /WR lines to the device. Provided that only one device is present and that 

it only has one register, no address decoding is necessary. To access this d 

evice from C simply prefix an appropriately named variable with "xdata". Thi 

s will cause the compiler to use MOVX A,@DTPR instructions when getting data 

 in or out. In actual fact the linker will try to allocate a real address to 

 this but, as no decoding is present, the device will simply be enabled by / 

WR or /RD. 

In practice life is rarely this simple. Usually a mixture of RAM, UARTS, por 

ts, EEPROM and other devices may all be attached to the 8031 by being mapped 

 into the xdata space. Some sort of decoding is provided by discrete logic o 

r (more usually) a PAL. 

Here the various registers of the different devices will appear at fixed loc 

ations in the xdata space. With normal on-chip resources the simple "data bo 

ok" name can be used to access them, so ideally these external devices shoul 

d be the same. 

There are three basic approaches to this: 

Use normal variables, char, ints etc, located by the linker 

Use pointers and offsets, either via the XBYTE macros or directly with user- 

defined pointers. 

Use the _At_ and _ORDER directives. 

In detail, these may be implemented as shown in the following sections. 

7.1 The XBYTE And XWORD Macros 

To allow memory-mapped devices to be accessed from C, a method is required t 

o effectively force pointers to point to fixed addresses. C51 provides many 

methods of achieving this, the simplest of which are the XBYTE[addr16] and X 

WORD[addr16] macros 

For instance: 

The byte wide PORT8_DDI register of a memory mapped IO device is at 8000H. T 

o access it from C it must be declared thus: 

    #include "absacc.h";   /*Contains macro definitions */ 

    #define port8_ddi   XBYTE[0x8000] 

    #define port8_data  XBYTE[0x8001] 

To use it then, 

    port8_ddi = 0xFF       ; 

    input_val = port8_data ; 

To access a word at an even external address: 

    #define word_reg XWORD[0x4000] 

    /* gives a word variable at 8000H */ 

Ignoring the pre-defined XWORD macro, the equivalent C line is: 

    #define word_reg_ptr ((unsigned int *) 0x24000L) 

    /*creates a pointer to a word (int) at address 8000H*/ 

To use this address then, 

    *word_reg_ptr = 0xFFFF ; 

Note that the address 8000H corresponds to 4000H words, hence the " 0x24000L 

 ". 

Here are some examples with the code produced: 

#define XBYTE ((unsigned char volatile *) 0x20000L) 

#define XWORD ((unsigned int volatile *) 0x20000L) 

main() { 

char x ; 

 int y ; 

x = XBYTE[0x8000]       ; 

0000 908000        MOV     DPTR,#08000H 

0003 E0            MOVX    A,@DPTR 

0004 FF            MOV     R7,A 

0005 8F00    R     MOV     x,R7 

y = XWORD[0x8000/sizeof(int)] ; 

} 

0007 908000        MOV     DPTR,#08000H 

000A E0            MOVX    A,@DPTR 

000B FE            MOV     R6,A 

000C A3            INC     DPTR 

000D E0            MOVX    A,@DPTR 

000E FF            MOV     R7,A 

000F 8E00    R     MOV     y,R6 

0011 8F00    R     MOV     y+01H,R7 

} 

0013         ?C0001: 

0013 22            RET 

However the address indicated by "word_reg" is fixed and can only be defined 

 at compile time, as the contents of the square brackets may only be a const 

ant. Any alteration to the indicated address is not possible with these macr 

o-based methods. This approach is therefore best suited to addressing locati 

ons that are fixed in hardware and unlikely to change at run time. 

Note the use of the volatile storage class modifier. This is essential to pr 

event the optimiser removing data reads from external ports. 

See section 7.4 for more details. 

Note: the header file "absacc.h" must be included at the top of the source f 

ile as shown above. This contains the prototype for the XBYTE macro. (see pa 

ge 9-15 in the C51 manual) 

7.2 Initialised XDATA Pointers 

In many cases the external address to be pointed at is known at compile time 

 but may need to be altered at some point during execution. Thus some method 

 of making a pointer point at an intial specific external address is require 

d. 

Probably the simplest way of setting up such a pointer is to let the C_INIT 

program set the pointer to a location. However the initial address must be k 

nown at compile time. If the pointer is to be altered at run time, just equa 

te it (without the "*" at run time) to the new address. 

Note: this automatic initialisation was not supported on earlier versions of 

 C51. 

Simply do: 

/* Spaced pointer */ 

  xdata char xdata *a_ptr = 0x8000 ; 

/* Generic Pointer */ 

  xdata char *a_ptr = 0x028000L ; 

Here the pointer is setup to point at xdata address 0x8000. Note that the sp 

aced *a_ptr can only point at xdata locations as a result of the second xdat 

a used in its declaration. In the generic *a_ptr case, the "02" tells C51 th 

at an xdata address is intended. 

An example might be: 

   6             xdata char xdata *ptr = 0x8000 ; 

   7 

   8 

   9             main() { 

  11   1         char x ; 

  13   1         ptr += 0xf0 ; 

0000 900000  R     MOV     DPTR,#ptr+01H 

0003 E0            MOVX    A,@DPTR 

0004 24F0          ADD     A,#0F0H 

0006 F0            MOVX    @DPTR,A 

0007 900000  R     MOV     DPTR,#ptr 

000A E0            MOVX    A,@DPTR 

000B 3400          ADDC    A,#00H 

000D F0            MOVX    @DPTR,A 

  15   1         x = *ptr ; 

  16   1 

  17   1         } 

000E E0            MOVX    A,@DPTR 

000F FE            MOV     R6,A 

0010 A3            INC     DPTR 

0011 E0            MOVX    A,@DPTR 

0012 F582          MOV     DPL,A 

0014 8E83          MOV     DPH,R6 

0016 E0            MOVX    A,@DPTR 

0017 F500    R     MOV     x,A 

  17   1         } 

0019 22            RET 

7.3 Run Time xdata Pointers 

The situation often occurs that you need to point at addresses in the xdata 

space which are only known at run time. Here the xdata pointer is setup in t 

he executable code. 

The best way to achieve this is to declare an "uncommitted" pointer at compi 

le time and to then equate it to an address when running: 

char xdata *xdata_ptr ;   /* Uncommitted pointer */ 

                    /* to xdata memory */ 

main() { 

xdata_ptr=(char xdata*) 0x8000 ; /*Point at 0x8000 in */ 

                                   /*xdata */ 

} 

An alternative is to declare a pointer to the xdata space and simply equate 

it to a variable. 

Here is an example: 

   char xdata *ptr ; /* This is a spaced pointer!!! */ 

   main(){ 

   start_address = 0x8000 ;  /*Variable containing address*/ 

                    /*to be pointed to */ 

0000 750080  R     MOV     start_address,#080H 

0003 750000  R     MOV     start_address+01H,#00H 

   ptr = start_address ; 

000C AE00    R     MOV     R6,start_address 

000E AF00    R     MOV     R7,start_address+01H 

0010 8E00    R     MOV     ptr,R6 

0012 8F00    R     MOV     ptr+01H,R7 

0014         ?C0001: 

   while(1) { 

   x = *ptr++ ; 

0014 0500    R     INC     ptr+01H 

0016 E500    R     MOV     A,ptr+01H 

0018 AE00    R     MOV     R6,ptr 

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本韩国精品在线| 欧美精品久久久久久久多人混战 | 日韩精彩视频在线观看| av午夜一区麻豆| 日本一区二区三区免费乱视频| 日本不卡一区二区三区| 欧美在线一二三四区| 中文字幕一区日韩精品欧美| 国产精品 欧美精品| 精品美女在线观看| 久久成人av少妇免费| 欧美成人精精品一区二区频| 麻豆一区二区三| 日韩精品一区二区三区三区免费| 日韩高清一级片| 欧美一区二区三区四区高清| 日本vs亚洲vs韩国一区三区| 欧美精品乱人伦久久久久久| 麻豆91精品91久久久的内涵| 欧美va亚洲va在线观看蝴蝶网| 国产一区二区三区四区在线观看| 精品国免费一区二区三区| 国产一区二区免费在线| 国产欧美视频一区二区三区| 成人av片在线观看| 玉米视频成人免费看| 777a∨成人精品桃花网| 国产一区二区在线视频| 国产精品久久久久久亚洲毛片 | 日韩国产在线观看| 日韩免费高清视频| 国产成人福利片| 亚洲另类色综合网站| 欧美一区二区三区免费| 国产成人精品免费一区二区| 怡红院av一区二区三区| 这里是久久伊人| 丁香亚洲综合激情啪啪综合| 一区二区日韩电影| 欧美不卡一区二区三区| 99re热这里只有精品视频| 午夜电影网一区| 在线成人小视频| 国产经典欧美精品| 一区二区激情小说| 久久综合给合久久狠狠狠97色69| 日韩电影免费在线观看网站| 欧美α欧美αv大片| 国产大片一区二区| 舔着乳尖日韩一区| 欧美国产日韩精品免费观看| 欧美日韩一区二区电影| 国内成人自拍视频| 一区av在线播放| 欧美精品一区二区三区四区| 日本道在线观看一区二区| 精品一区二区三区免费观看| 亚洲欧美另类综合偷拍| 欧美精品一区二区三区在线播放| 色丁香久综合在线久综合在线观看| 六月婷婷色综合| 一区二区三区精品| 国产精品视频一二| 日韩三级.com| 欧美亚洲自拍偷拍| 波多野洁衣一区| 国产一区二区三区久久悠悠色av| 亚洲国产毛片aaaaa无费看 | 高清不卡一二三区| 日本亚洲免费观看| 亚洲综合区在线| 1024国产精品| 国产日韩欧美高清| 精品国产乱码91久久久久久网站| 欧美日韩中文字幕一区二区| www.av精品| 久久99国内精品| 亚洲国产成人av| 国产人久久人人人人爽| 日韩天堂在线观看| 欧美无砖专区一中文字| 岛国精品一区二区| 国产精品资源在线看| 午夜欧美电影在线观看| 国产精品免费视频网站| 久久久久久97三级| 精品日韩一区二区三区| 制服丝袜在线91| 欧美精品 日韩| 欧美视频精品在线观看| 91高清视频免费看| 日本丰满少妇一区二区三区| 91色视频在线| 一本大道久久a久久综合婷婷| 国产精品一区二区免费不卡| 午夜精品免费在线观看| 亚洲一区欧美一区| 亚洲一区二区三区影院| 亚洲国产精品一区二区尤物区| 亚洲一区二区三区不卡国产欧美| 亚洲一区视频在线| 秋霞av亚洲一区二区三| 裸体健美xxxx欧美裸体表演| 久久精品国产一区二区三区免费看| 蜜桃一区二区三区在线| 久久成人av少妇免费| 国产乱人伦偷精品视频免下载| 精品一区二区国语对白| 国产精品一区在线| 不卡区在线中文字幕| 日本精品免费观看高清观看| 欧美伊人久久大香线蕉综合69| 色88888久久久久久影院按摩| 欧美日韩一二三区| 91精品国产手机| 欧美一级爆毛片| 2019国产精品| 亚洲日本va午夜在线影院| 国产精品久久久久桃色tv| 一区二区在线观看不卡| 亚洲成a人片在线观看中文| 免费观看成人av| 成人综合婷婷国产精品久久 | 日一区二区三区| 国产在线视频一区二区| av中文一区二区三区| 欧美日韩免费高清一区色橹橹| 日韩手机在线导航| 国产精品麻豆欧美日韩ww| 亚洲一级二级三级在线免费观看| 免费成人美女在线观看.| 国产综合色视频| 在线国产电影不卡| 精品国产一区二区精华| ㊣最新国产の精品bt伙计久久| 亚洲成人精品在线观看| 国产成人精品午夜视频免费 | 欧美性生活一区| 久久综合狠狠综合久久综合88 | 中文字幕一区三区| 日韩综合一区二区| 国产成人av影院| 欧美日韩在线精品一区二区三区激情 | 欧美日韩性生活| 国产校园另类小说区| 亚洲尤物在线视频观看| 国产一区二区三区香蕉| 欧美日韩三级在线| 欧美国产精品久久| 免费看欧美美女黄的网站| 99久久免费精品高清特色大片| 欧美sm美女调教| 亚洲动漫第一页| 成人网在线免费视频| 欧美一区二区性放荡片| 亚洲天堂成人在线观看| 国产乱码一区二区三区| 91精品免费在线| 亚洲综合一区二区| 成人久久久精品乱码一区二区三区 | 一本色道综合亚洲| 国产日产精品一区| 激情另类小说区图片区视频区| 色素色在线综合| 国产精品美女久久久久久久久| 久草这里只有精品视频| 欧美日韩免费视频| 亚洲精品免费看| 99r精品视频| 中文字幕欧美国产| 国产精品一区二区在线播放| 日韩欧美亚洲另类制服综合在线| 亚洲a一区二区| 色诱视频网站一区| 亚洲精品国产精品乱码不99| 国产成人综合网站| 欧美一级一区二区| 日韩电影在线免费观看| 欧美日韩国产片| 午夜精品影院在线观看| 欧美视频三区在线播放| 亚洲最新视频在线观看| 91国偷自产一区二区开放时间| 亚洲欧美日韩精品久久久久| eeuss鲁片一区二区三区在线观看| 国产日韩影视精品| 国产一区二区不卡老阿姨| 国产午夜精品久久| 成人免费视频视频| 国产精品人妖ts系列视频| 成人激情黄色小说| 亚洲天堂中文字幕| 色综合天天在线| 亚洲免费高清视频在线| 91九色最新地址| 亚洲女女做受ⅹxx高潮| 欧美福利视频导航| 久久精品国产澳门| 久久精品这里都是精品| aaa亚洲精品一二三区|