c-声明sfr地址时出现编译错误



我正在一个基于8051的MCU STC16C65A上工作,我希望它通过P2.0发射PWM,我从他们的手册中复制和修改这个代码:

#include "8051.h"
sfr AUXR = 0x8e;
//Auxiliary register T0 interrupt service routine
void t0int() interrupt 1           //(location at 000BH)
{
}
void main()
{
AUXR = 0x80;
//timer0 work in 1T mode
TMOD = 0x06;                  //set timer0 as counter mode2 (8-bit auto-reload)
TL0 = TH0 = 0xff;               //fill with 0xff to count one time
TR0 = 1;                        //timer0 start run
ET0 = 1;                        //enable T0 interrupt
EA = 1;                         //open global interrupt switch
IF P2.0 = 0 THEN P2.0 = 1 ELSE P2.0 = 0;
while (1);
}

但当我使用MCU 8051编译它时,ide出现语法错误,在sfr AUXR=0x8e中忽略了声明;我认为使用的库(8051.reg(是一个通用的库,而不是他们在手册中建议的reg51.h(oudated(,我没有使用它,因为会出现库过期的错误消息谁能帮我?也许我必须为那个指针选择另一个地址?提前感谢

SDCC是一个与Keil C51不同的编译器,您必须期望C标准的扩展有所不同。SFR的声明是一种延伸。

请使用记录的语法:

__sfr __at(0x8e) AUXR;

最新更新