One of Keil C51's keyword extensions to the C language: _at_

Publisher:Tianyun2021Latest update time:2018-06-21 Source: eefocusKeywords:Keil  C51  _at_ Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

 The _at_ keyword is used to specify the address of the variable when defining the variable.


The following are examples of using the _at_ keyword:


struct link

  {

  struct link idata *next;

  char code *test;

  };


struct link list idata _at_ 0x40; /* Define the structure located at address 0x40 in the lower 128 bytes of the internal RAM*/

char xdata text[256] _at_ 0xE000; /* define the array at the external RAM 0xE000 address */

int xdata i1 _at_ 0x8000; /* define an integer variable located at the address 0x8000 in external RAM*/

volatile char xdata IO _at_ 0xFFE8; /* Define external IO with address 0xFFE8 */

char far ftext[256] _at_ 0x02E000; /* define the array at the external RAM 0x2E000 address */


void main ( void ) {

  link.next = (void *) 0;

  i1 = 0x1234;

  text[0] = 'a';

  IO = 6;

  ftext[0] = 'f';

}


In a .c file, these variables are defined as above, and can be referenced in another .c file as follows:


struct link

  {

  struct link idata *next;

  char code *test;

  };


extern struct link idata list;    

extern char xdata text[256];      

extern int xdata i1;              

extern volatile char xdata IO;    


Keywords:Keil  C51  _at_ Reference address:One of Keil C51's keyword extensions to the C language: _at_

Previous article:Keil C51's second keyword extension to C language: alien
Next article:51 MCU STC89C52 infrared decoding

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号