Just looking at 52 SCM and GPS communication program, see a function, absacc.h, seemingly never encountered, Baidu a bit, combined with their own understanding, sorted as follows: http://blog.sina.com.cn/s/blog_4__ function

Source: Internet
Author: User
Tags volatile

Just looking at 52 SCM and GPS communication program, see a function, absacc.h, seemingly never encountered, Baidu a bit, combined with their own understanding, sorted as follows:

Http://blog.sina.com.cn/s/blog_4f8cdc9e0100g1qp.html "51 single chip microcomputer KEILC header document ABSACC.H function"

http://apps.hi.baidu.com/share/detail/716779 "Absacc.h Library Introduction"

Http://blog.sina.com.cn/s/blog_5f0187c50100e0nt.html the role of #include<absacc.h> (turn)

Just look at these few basic enough, should be able to understand what this document is:

In a program, use the macros defined in the #include<absacc.h> to access an absolute address, including:
CByte, Xbyte, Pword, Dbyte, Cword, Xword, Pbyte, DWORD

For example:
RVAL=CBYTE[0X0002]; point to 0002h Address of program memory
Rval=xword [0x0002]; 0004h address pointing to external RAM//word is a word, two bytes, so 0004h

#define COM8255 XBYTE[0X060FF]//After COM8255, single-chip port P0 and P2 joint output 0X060FF Absolute Physical address (address pointing to the 82c55 instruction register)
#define PA8255 XBYTE[0X000FF]//After PA8255, single-chip port P0 and P2 federated output 0X000FF Absolute Physical address (address to a group a port register of 82c55)
#define PB8255 XBYTE[0X020FF]//After PB8255, single-chip port P0 and P2 joint output 0X020FF Absolute Physical address (address to the B-group Port Register of 82c55)
#define PC8255 XBYTE[0X040FF]//After PC8255, single-chip port P0 and P2 joint output 0X040FF Absolute Physical address (address to the C-Group Port Register of 82c55)

Similarly, in the GPS and SCM Communication, the following macro definition is good to understand:

#define GPS_LG0 xbyte[0x0]
#define GPS_LG1 xbyte[0x1000]
#define GPS_LG2 xbyte[0x2000]
#define GPS_LG3 xbyte[0x3000]
#define GPS_LAT0 xbyte[0x4000]
#define GPS_LAT1 xbyte[0x5000]
#define GPS_LAT2 xbyte[0x6000]
#define GPS_LAT3 xbyte[0x7000]
#define UTC0 xbyte[0xc000]
#define UTC1 xbyte[0xd000]
#define UTC2 xbyte[0xe000]
#define UTC3 xbyte[0xf000]

#define Snum xbyte[0xa000]

is to use Xbyte to make the defined macro point to an actual physical address.

In Keil, you can see the definition of this file directly:

/*--------------------------------------------------------------------------
Absacc. H

Direct access to 8051, extended 8051 and Philips 80c51mx memory areas.
Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
All rights reserved.
--------------------------------------------------------------------------*/

#ifndef __absacc_h__
#define __absacc_h__

#define CByte ((unsigned char volatile code *) 0)
#define Dbyte ((unsigned char volatile data *) 0)
#define PBYTE ((unsigned char volatile pdata *) 0)
#define Xbyte ((unsigned char volatile xdata *) 0)

#define CWORD ((unsigned int volatile code *) 0)
#define DWORD ((unsigned int volatile data *) 0)
#define PWORD ((unsigned int volatile pdata *) 0)
#define XWORD ((unsigned int volatile xdata *) 0)


#ifdef __cx51__
#define FVAR (object, addr) (* (object volatile FAR *) (addr))
#define Farray (object, Base) (object volatile FAR *) (base)
#define Fcvar (object, addr) (* ((Object const FAR *) (addr))
#define Fcarray (object, Base) (Object const FAR *) (base)
#else
#define FVAR (object, addr) (* (object volatile FAR *) ((addr) +0x10000l))
#define Fcvar (object, addr) (* ((Object const FAR *) ((addr) +0x810000l))
#define Farray (object, Base) (object volatile FAR *) ((base) +0x10000l)
#define Fcarray (object, Base) (Object const FAR *) ((base) +0x810000l)
#endif

#endif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.