FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    Single Chip Microcomputer C Language Tutorial Chapter 16 - Channel - C51 Pointer

     

    Single Chip Microcomputer C Language Tutorial Chapter 16 - Channel - C51 Pointer The pointer is the memory area address where variables or data is located. If a character type variable STR stores 51H in the memory cell DATA area, the 51h address of the DATA area is the pointer of the variable STR. In the C language pointer is a very important concept, correctly and efficiently use the pointer type data, which can more effectively express complex data structures, can more efficiently use array or variables, which can easily process memory or other stores. . The reason why the pointer can be such as effective operation data is because both the program's instructions, constants, variables, or special registers are stored in memory cells or corresponding storage areas, these storage areas are divided by bytes, each storage Both the unit can read or write data with unique numbers, this number is the address of the stored unit, and the action read and writes this number is called addressing, and can access any one of the storage area by addressing. Visible units, and this feature is a variable or array or the like is not possible. The C language has also introduced the data type of the pointer type, which is specifically used to determine the address of other types of data. With a variable to store the address of another variable, the variable used to store the variable address is called "pointer variable." If the variable strip is used to store the address of the STR variable at the beginning of the article 51H, the variable Strip is the pointer variable. Below with a chart to explain the pointers of the variable and two different concepts of pointer variables. The pointer to the variable is the address of the variable, and the address operator '&' is used to obtain the assigned pointer variable. & Str is the address of the variable STR. Use statements strip = & STR to store the acquired STR pointer in the Strip pointer variable. The value of Strip changes to 51H. It can be seen that the content of the pointer variable is the address of another variable, and the variable belongs to the address is called the variable pointed to by the pointer variable. To access the variable Str, in addition to access to the 'STR' variable name, you can access the variable address. The method is to use & STR to extract the emission address and assign the Strip pointer variable, and then you can use * Strip to access the STR. '*' Is a pointer operator that uses it to obtain the value of the address pointed to by the pointer variable. The address pointed to by the pointer variable Strip is 51h, while the value in 51h is 40h, then the value obtained by * Strip is 40h. The variables are required before using the pointer variables before using other types of variables, and the form is similar, The general form is as follows: Data Type [Memory Type] * Variable Name; UNSIGNED Char XData * Pi // The pointer will occupy the bin, and the pointer itself is stored in the compiler default storage area. CHAR type to the XDATA storage area UNSIGNED Char XData * Data Pi; // In addition to the pointer itself specifies in the DATA area, the rest INT * pi; // Defined as a general pointer, the pointer itself stores the compiler default storage area, accounting for three bytes in the defined form "data type" refers to the type of variable pointed to by the defined pointer variable. "Memory Type" It is an extension identifier for compiler compile, which is optional. When there is no "Memory Type" option, it is defined as one Specificity pointers, if there is a Memory Type option, it is defined as a memory-based pointer. Limited to the addressing range of the 51 chip, The maximum value of the pointer variable is 0xffff, which determines that the general pointer will occupy 3 bytes of memory, and the first word save the pointer memory type encoding, and the latter is stored in the high and low order of the pointer. Based on memory-based pointers, because of one or two bytes, Idata, Data, PDATA memory pointers, and xData will occupy two bytes because they do not recognize memory types, IDATA, DATA, and PDATA memory pointers. It is known that the clear definition of the pointer can save memory overhead, which is useful in projects that strictly require program volume. There are many ways to use pointers, limited to paracenesis, which can only be introduced to it. The following is used in routine modification when the constant is described, and the basic method of use of the pointer is used. #include // Prepare the name of the special register, the name of the special register is defined as P1 Void main (void) { // Define the pattern data, and the data is stored in the CODE area in the film. Unsigned char code design [] = {0xFF, 0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F, 0x7f, 0xbf, 0xDF, 0xef, 0xF7, 0xfb, 0xfd, 0xfe, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xe0, 0xc0, 0x80, 0x0, 0xE7, 0xDB, 0xBD, 0x7E, 0xFF}; Unsigned int a; / / Define variables used by the loop UNSIGNED Char B; UNSIGNED Char Code * DSI; / / Define pointers based on the Code area Do { DSI = & design [0]; // Acquired an address of the first unit of array For (b = 0; b<32; b ++) { } WHILE (1); } For (a = 0; a<30000; a ++); // delay for a while P1 = * DSI; // Take data from the address points to the P1 port DSI ++; // Pointer plus one, In order to understand the working principle of the pointer, you can use the KEIL UV2 software emulator to view each variable and memory. value. Compile the program and execute, then turn on the variable window, as shown. You can find the variable of the pointer with a single step. As shown in the figure, the loop is executed in the program to the second time. At this time, the pointer DSI points to the address of the C: 0x0004, the value of this address is 0xFE. The value of each address unit can be viewed at the memory window. Using this method not only can help better understand the grammar or procedure during learning, but also makes you more accurate writing programs or solutions in actual use. , Reading the full text, the technology area About μClinux transplantation on ARM7 S3C4510B Multi-looped into charge and discharge controller design Interrupt service routines for ARM embedded systems LED dimming engine design based on 8-bit MCU How to display Chinese characters, ASCII characters and color graphics on the LCD monitor

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us