新手误购入8051f040开发板,各种不会。。
0、中断问题
这样初始化之后使用timer0定时器中断貌似没反映
void Init(void){
WDTCN = 0xDE; //禁止看门狗定时器
WDTCN = 0xAD;
SFRPAGE = CONFIG_PAGE;
OSCICN |= 0x03; //系统内部振荡器
XBR2 = 0x40; //交叉开关使能
ET0 = 1; //T0中断
SFRPAGE = TIMER01_PAGE;
TR0 = 1; //计时器
TMOD = 0x04;
CKCON = 0x04;
SFRPAGE = 0xA7;
P3MDOUT = 0x02;
SFRPAGE = CONFIG_PAGE;
}
1、有没有关于8051f的书籍(还是就看51单片机的书呢?
2、
获取定时器高位/低位的值时要切换SFR页么?
这是初始化
SFRPAGE = CONFIG_PAGE;
WDTCN = 0xDE; //close watch dog
WDTCN = 0xAD;
XBR2 = 0x40; //enable cross
OSCICN |= 0x83; //enable osc
SFRPAGE = TIMER01_PAGE;
CKCON = 0x01; //timer frequency/4
SFRPAGE = CONFIG_PAGE;
这是计时
TR0=1; //start
while(B1);
TR0=0; //stop
这是获得数值
SFRPAGE = TIMER01_PAGE;
th=TH0;
tl=TL0&0x1F;
SFRPAGE = CONFIG_PAGE;
|