我以PIC1250.H的名称找到了该PIC单片机的头文件,但无法了解其中使用的某些语法。

该文件的来源是:

/*
 *  Header file for the Microchip
 *  PIC 12c508 chip
 *  PIC 12c509 chip
 *  Baseline Microcontrollers
 */

static volatile unsigned char   RTCC    @ 0x01;
static volatile unsigned char   TMR0    @ 0x01;
static volatile unsigned char   PCL @ 0x02;
static volatile unsigned char   STATUS  @ 0x03;
static          unsigned char   FSR @ 0x04;
static volatile unsigned char   OSCCAL  @ 0x05;
static volatile unsigned char   GPIO    @ 0x06;

static          unsigned char control   OPTION  @ 0x00;
static volatile unsigned char control   TRIS    @ 0x06;

/*  STATUS bits */
static bit  GPWUF   @ (unsigned)&STATUS*8+7;
static bit  PA0 @ (unsigned)&STATUS*8+5;
static bit  TO  @ (unsigned)&STATUS*8+4;
static bit  PD  @ (unsigned)&STATUS*8+3;
static bit  ZERO    @ (unsigned)&STATUS*8+2;
static bit  DC  @ (unsigned)&STATUS*8+1;
static bit  CARRY   @ (unsigned)&STATUS*8+0;

/*  OPTION bits */
#define     GPWU    (1<<7)
#define     GPPU    (1<<6)
#define     T0CS    (1<<5)
#define     T0SE    (1<<4)
#define     PSA (1<<3)
#define     PS2 (1<<2)
#define     PS1 (1<<1)
#define     PS0 (1<<0)

/*  OSCCAL bits */
static bit  CAL7    @ (unsigned)&OSCCAL*8+7;
static bit  CAL6    @ (unsigned)&OSCCAL*8+6;
static bit  CAL5    @ (unsigned)&OSCCAL*8+5;
static bit  CAL4    @ (unsigned)&OSCCAL*8+4;

/*  GPIO bits   */
static bit  GP5 @ (unsigned)&GPIO*8+5;
static bit  GP4 @ (unsigned)&GPIO*8+4;
static bit  GP3 @ (unsigned)&GPIO*8+3;
static bit  GP2 @ (unsigned)&GPIO*8+2;
static bit  GP1 @ (unsigned)&GPIO*8+1;
static bit  GP0 @ (unsigned)&GPIO*8+0;

#define CONFIG_ADDR 0xFFF
#define FOSC0       0x01
#define FOSC1       0x02
#define WDTE        0x04
#define CP      0x08
#define MCLRE       0x0F

我无法理解整个modifer数据类型@声明内容。有人可以帮我吗?我只是这个新手。

最佳答案

这是一个编译器扩展。

从PIC MPLAB XC8编译器文档(重点是我的):



注意,MPLAB XC8并不是唯一具有相同@结构的编译器,该结构可以将对象放置在特定的存储器位置。

另一个众所周知的编译器是Freescale CodeWarrior(至少适用于HCS08)。

另一个是IAR C编译器(至少适用于MSP430和AVR)。

关于c - @登录C变量声明,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15955856/

10-14 15:18