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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? c514.txt

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

標  題: C51 Primer (3) Variables and Constants 

發信站: 南京大學小百合站 (Wed Nov 24 09:50:49 1999), 轉信 

  

  

3 Declaring Variables And Constants 

3.1 Constants 

The most basic requirement when writing any program is to know how to alloca 

te storage for program data. Constants are the simplest; these can reside in 

 the code (Eprom) area or as constants held in RAM and initialised at runtim 

e. Obviously, the former really are constants and cannot be changed. 

While the latter type are relatively commonplace on big systems (Microsoft C 

), in 8051 applications the code required to set them up is often best used 

elsewhere. Also, access is generally faster to ROMmed constants than RAM one 

s if the RAM is external to the chip, as ROM "MOVC A,@DPTR" instruction cycl 

e is much faster than the RAM "MOVX A,@DPTR". 

Examples of Eprommed constant data are: 

    code unsigned char coolant_temp = 0x02 ; 

    code unsigned char look_up table[5]='1','2','3','4''} ; 

    code unsigned int  pressure = 4 ; 

Note that "const" does not mean "code". Objects declared as "const" will act 

ually end up in the data memory area determined by the current memory model. 

  

Obviously, any large lookup tables should be located in the CODE area - a de 

claration might be: 

    /* Base FuelMap    */ 

    /* x = Load : y = engine speed : output = Injector PW, 0 - 8.16ms */ 

    /* (x_size,y_size, 

        x_breakpoints, 

        y_breakpoints, 

        map_data) 

    */ 

    code unsigned char default_base_fuel_PW_map[] = { 

                0x08,0x08, 

                0x00,.0x00,0x00,0x09,0x41,0x80,0xC0,0xFF, 

                0x00,0x00,0x13,0x1A,0x26,0x33,0x80,0xFF, 

                0x00,0x00,0x00,0x09,0x41,0x80,0x66,0x66, 

                0x00,0x00,0x00,0x09,0x41,0x80,0x66,0x66, 

                0x00,0x00,0x00,0x00,0x4D,0x63,0x66,0x66, 

                0x00,0x00,0x00,0x02,0x4D,0x63,0x66,0x66, 

                0x00,0x00,0x00,0x05,0x4A,0x46,0x40,0x40, 

                0x00,0x00,0x00,0x08,0x43,0x43,0x3D,0x3A, 

                0x00,0x00,0x00,0x00,0x2D,0x4D,0x56,0x4D, 

                0x00,0x00,0x00,0x00,0x21,0x56,0x6C,0x6F 

            } ; 

With large objects like the above it is obviously important to state a memor 

y space. When working in the SMALL model in particular, it is very easy to f 

ill up the on-chip RAM with just a single table! 

RAM constants would be: 

    unsigned char scale_factor = 128    ; 

    unsigned int fuel_constant = 0xFD34 ; 

These could, however, have their values modified during program execution. A 

s such, they are more properly thought of as initialised variables - see sec 

tion 3.2.2 

3.2 Variables 

3.2.1 Uninitialised Variables 

Naturally, all variables exist in RAM, the configuration of which is given i 

n section 2.1.1. 

The #pragma SMALL line will determine the overall memory model. In this case 

, all variables are placed within the on-chip RAM. However, specific variabl 

es can be forced elsewhere as follows: 

    #pragma SMALL 

      . 

      . 

      xdata unsigned char engine_speed ; 

      xdata char big_variable_array[192] ; 

This will have engine_speed placed in an external RAM chip. Note that no ini 

tial value is written to engine_speed, so the programmer must not read this 

before writing it with a start value! This xdata placement may be done to al 

low engine_speed to be traced "on the fly", by an in-circuit emulator for ex 

ample. 

In the case of the array, it would not be sensible to place this in the on-c 

hip RAM because it would soon get filled up with only 128 bytes available. T 

his is a very important point - never forget that the 8051 has very limited 

on-chip RAM. 

Another example is: 

      . 

    #pragma LARGE 

      . 

      . 

      . 

      function(data unsigned char para1) 

      { 

      data unsigned char local_variable ; 

      . 

      . 

      . 

      . 

      } 

Here the passed parameters are forced into fast directly addressed internal 

locations to reduce the time and code overhead for calling the function, eve 

n though the memory model would normally force all data into XDATA. 

In this case it would be better to declare the function as SMALL, even thoug 

h the prevailing memory model is large. This is extremely useful for produci 

ng a few fast executing functions within a very big LARGE model program. 

On a system using paged external RAM on Port 0, the appropriate directive is 

 "pdata". 

See notes in section 2.1.3 for details on how to best locate variables. 

3.2.2 Initialised Variables 

To force certain variables to a start value in an overall system setup funct 

ion, for example, it is useful to be able to declare and initialise variable 

s in one operation. This is performed thus: 

    unsigned int engine_speed = 0 ; 

    function() 

      { 

      . 

      . 

      . 

      } 

Here the value "0" will be written to the variable before any function can a 

ccess it. To achieve this, the compiler collects together all such initialis 

ed variables from around the system into a summary table. A runtime function 

 named "C_INIT" is called by the "startup.obj" program which writes the tabl 

e values into the appropriate RAM location, thus initialising them. 

Immediately afterwards, the first C program "main()" is called. Therefore no 

 read before write can occur, as C_INIT gets there first. The only point to 

note is that you must modify the "startup.a51" program to tell C_INIT the lo 

cation and size of the RAM you are using. For the large model, XDATASTART an 

d XDATALEN are the appropriate parameters to change. 

3.3 Watchdogs With Large Amounts Of Initialised Data 

In large programs the situation may arise that the initialisation takes long 

er to complete than the watchdog timeout period. The result is that the cpu 

will reset before reaching main() where presumably a watchdog refresh action 

 would have been taken. 

To allow for this the INIT.A51 assembler file, located in the \C51p\LIB dire 

ctory, should be modified. 

;__________________________________________________________; 

This file is part of the C-51 Compiler package Copyright KEIL ELEKTRONIK  Gm 

bH 1990 

;__________________________________________________________; 

INIT.A51:  This code is executed if the application program contains initial 

ised variables at file level. 

; _________________________________________________________; 

;  User-defined Watch-Dog Refresh. 

; 

;  If the C application containing many initialised variables uses a watchdo 

g it 

;  might be possible that the user has to include a watchdog refresh in the 

;  initialisation process. The watchdog refresh routine can be included in t 

he 

;  following MACRO and can alter all CPU registers except DPTR. 

; 

WATCHDOG    MACRO 

            ;Include any Watchdog refresh code here 

        P6 ^= watchdog_refresh  ;Special application code 

        ENDM 

;____________________________________ 

        NAME    ?C_INIT 

?C_C51STARTUP SEGMENT CODE 

?C_INITSEG    SEGMENT CODE  ; Segment with Initialising Data 

              EXTRN CODE (MAIN) 

              PUBLIC    ?C_START 

              RSEG    ?C_C51STARTUP INITEND:    LJMP    MAIN 

?C_START: 

              MOV    DPTR,#?C_INITSEG 

LOOP: 

              WATCHDOG   ;<<_ WATCHDOG REFRESH CODE ADDED HERE! 

              CLR    A 

              MOV    R6,#1 

              MOVC    A,@A+DPTR 

              JZ    INITEND 

              INC    DPTR 

              MOV    R7,A 

. 

. 

. 

.  Large initialisation loop code 

. 

. 

. 

        XCH    A,R0 

        XCH    A,R2 

        XCH    A,DPH 

        XCH    A,R2 

        DJNZ    R7,XLoop 

        DJNZ    R6,XLoop 

        SJMP    Loop 

        LJMP MAIN              ; C51 Program start 

        RSEG    ?C_INITSEG 

        DB    0 

        END 

A special empty macro named WATCHDOG is provided which should be altered to 

contain your normal watchdog refresh procedure. Subsequently, this is automa 

tically inserted into each of the initialisation loops within the body of IN 

IT.A51. 

3.4 C51 Variables 

3.4.1 Variable Types 

Variables within a processor are represented by either bits, bytes, words or 

 long words, corresponding to 1, 8, 16 and 32 bits per variable. C51 variabl 

es are similarly based, for example: 

bit            =1 bit         0 - 1 

char           =8 bits        0 - +/- 127 

unsigned char  =8 bits        0 - 255 

int            =16 bits       0 - +/-32768 

unsigned int   =16 bits       q0 - 65535 

long           =32 bits       0 - +/- 2.147483648x109 

unsigned long  =32 bits       0 - 4.29496795x109 

float          =32 bits       +/-1.176E-38 

                              to +/-3.4E+38 

pointer        =24/16/8 bits  Variable address 

Typical declarations would be: 

    xdata unsigned char battery_volts ; 

    idata int correction_factor       ; 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
1区2区3区国产精品| 日韩成人午夜电影| jizz一区二区| 国产日韩欧美综合在线| 国内外精品视频| 精品国产百合女同互慰| 捆绑紧缚一区二区三区视频| 这里只有精品99re| 秋霞电影一区二区| 日韩欧美精品在线| 另类小说视频一区二区| 欧美成va人片在线观看| 麻豆91在线播放免费| 欧美一区二视频| 日韩电影网1区2区| 精品久久久久一区二区国产| 久久超碰97中文字幕| 久久欧美一区二区| 国产精品99久久久久久宅男| 亚洲国产成人私人影院tom| 成人三级伦理片| 中文字幕一区二区三区乱码在线| av午夜一区麻豆| 亚洲女人小视频在线观看| 91蝌蚪porny九色| 亚洲高清视频在线| 7777精品伊人久久久大香线蕉超级流畅| 五月婷婷综合激情| 日韩一区二区三区免费观看| 玖玖九九国产精品| 国产三级一区二区| av不卡在线观看| 亚洲精品免费在线| 欧美日产在线观看| 精品一区精品二区高清| 国产女同互慰高潮91漫画| 成人av高清在线| 一区二区三区四区乱视频| 欧美日韩大陆一区二区| 免费观看在线综合| 久久精品人人做人人爽人人| 成人av综合一区| 亚洲国产一区在线观看| 欧美一激情一区二区三区| 久久99国产精品久久99果冻传媒| 久久久电影一区二区三区| 99视频一区二区三区| 亚洲国产精品人人做人人爽| 日韩一区二区电影在线| 高清国产一区二区| 亚洲制服丝袜在线| 日韩精品中文字幕一区二区三区| 国产成人8x视频一区二区| 亚洲乱码一区二区三区在线观看| 欧美巨大另类极品videosbest | 精品欧美一区二区三区精品久久| 国产精品资源在线看| 亚洲色图清纯唯美| 欧美一卡二卡三卡| 成人蜜臀av电影| 午夜国产精品一区| 国产欧美日韩在线视频| 欧美视频在线不卡| 国产一区三区三区| 一区二区三区日本| 国产亚洲视频系列| 欧美视频一区在线| 成人综合婷婷国产精品久久蜜臀| 亚洲小说春色综合另类电影| 久久夜色精品一区| 欧美做爰猛烈大尺度电影无法无天| 麻豆91在线播放免费| 亚洲女爱视频在线| 久久色在线视频| 欧美日韩一级黄| 成人午夜激情视频| 日韩av中文字幕一区二区三区| 国产精品无人区| 日韩欧美成人激情| 在线一区二区三区| 国内偷窥港台综合视频在线播放| 亚洲精品日韩综合观看成人91| 精品福利一二区| 欧美色倩网站大全免费| 国产成人aaa| 六月丁香综合在线视频| 亚洲综合成人在线| 国产精品剧情在线亚洲| 日韩精品在线一区| 欧美日韩中文一区| 99久久婷婷国产综合精品| 精品综合久久久久久8888| 一区二区日韩电影| 国产精品午夜免费| 欧美精品一区二区久久婷婷| 欧美日韩亚洲不卡| 91香蕉国产在线观看软件| 国产不卡一区视频| 美女精品一区二区| 亚洲v中文字幕| 综合久久综合久久| 中文字幕免费在线观看视频一区| 欧美xxxxxxxx| 日韩一级大片在线观看| 欧美精品色综合| 在线观看视频欧美| 91丨porny丨国产入口| 国产盗摄一区二区| 麻豆精品一区二区综合av| 视频在线在亚洲| 亚洲一区二区三区在线| 亚洲视频一区二区在线| 国产精品色眯眯| 久久久99免费| 欧美精品一区二区三| 日韩精品在线网站| 欧美一卡二卡在线观看| 91精品国产综合久久香蕉麻豆| 欧美亚洲国产一区二区三区| 色综合天天综合给合国产| 久久久久久免费| 91精品国产乱码久久蜜臀| 欧美欧美欧美欧美| 欧美日韩一区二区三区不卡| 91九色最新地址| 91官网在线观看| 91免费小视频| 色综合久久久久综合| 99re亚洲国产精品| 91在线观看地址| 91精品办公室少妇高潮对白| 91黄视频在线观看| 91久久香蕉国产日韩欧美9色| 91天堂素人约啪| 在线观看国产日韩| 在线观看视频91| 欧美日韩国产影片| 欧美一区二区福利在线| 日韩欧美一区在线观看| 精品久久国产字幕高潮| 精品国产sm最大网站免费看| 亚洲精品在线电影| 国产香蕉久久精品综合网| 国产日韩欧美综合在线| 国产精品理论在线观看| 亚洲欧美在线视频| 洋洋av久久久久久久一区| 亚洲国产aⅴ成人精品无吗| 日韩电影网1区2区| 国模冰冰炮一区二区| 国产成人精品免费| 91影院在线观看| 欧美日韩综合色| 欧美一区二区成人| 国产日产亚洲精品系列| 国产精品美女一区二区在线观看| 亚洲欧洲国产日本综合| 亚洲综合另类小说| 秋霞午夜鲁丝一区二区老狼| 国内成人精品2018免费看| 成人性生交大合| 色婷婷综合久久久久中文| 欧美日韩一二三区| 久久综合九色欧美综合狠狠| 国产农村妇女精品| 亚洲精品久久7777| 日本欧美一区二区三区乱码| 国产在线观看一区二区| 99精品久久免费看蜜臀剧情介绍 | 韩国欧美一区二区| 丰满少妇久久久久久久| 欧美影院一区二区| 欧美成人精品1314www| 中文字幕二三区不卡| 一区二区三区.www| 精品在线免费观看| 91天堂素人约啪| 日韩欧美一二区| 国产精品嫩草影院av蜜臀| 亚洲国产精品久久人人爱蜜臀| 麻豆成人免费电影| 91麻豆文化传媒在线观看| 在线综合+亚洲+欧美中文字幕| 久久久青草青青国产亚洲免观| 综合在线观看色| 麻豆成人综合网| 91香蕉国产在线观看软件| 日韩一级二级三级| 亚洲欧美色图小说| 久久成人av少妇免费| 色婷婷亚洲婷婷| 精品国产乱码久久久久久蜜臀 | 九九九久久久精品| 色国产综合视频| 久久久美女毛片| 亚洲电影在线免费观看| 国产成人8x视频一区二区| 欧美美女一区二区三区| 中文字幕av在线一区二区三区| 青青青伊人色综合久久|