标题:
STC12C20xx单片机EEROM测试程序
[打印本页]
作者:
gqzjl
时间:
2021-2-6 14:47
标题:
STC12C20xx单片机EEROM测试程序
先上程序
#include "reg51.h"
//-----------------------------------------------
/* define constants */
#define FOSC 11059200L
//#define MODE1T //Timer clock mode, comment this line is 12T mode, uncomment is 1T mode
#ifdef MODE1T
#define F38_4KHz (256-FOSC/2/38400) //38.4KHz frequency calculation method of 1T mode
#else
#define F38_4KHz (256-FOSC/2/12/38400) //38.4KHz frequency calculation method of 12T mode
#endif
/* define SFR */
sfr AUXR = 0x8e; //Auxiliary register
sfr WAKE_CLKO = 0x8f; //wakeup and clock output control register
sbit T1CLKO = P1^1; //timer1 clock output pin
//-----------------------------------------------
/* main program */
void main()
{
#ifdef MODE1T
AUXR = 0x40; //timer1 work in 1T mode
#endif
TMOD = 0x20; //set timer1 as mode2 (8-bit auto-reload)
TL1 = F38_4KHz; //initial timer1
TH1 = F38_4KHz; //initial timer1
TR1 = 1; //timer1 start running
WAKE_CLKO = 0x02; //enable timer1 clock output
while (1); //loop
}
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1