/* --- STC12C5Axx Series Programmable Clock Output Demo ------------*/ #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 sfr BRT = 0x9c; sbit BRTCLKO = P1^0; //BRT clock output pin //----------------------------------------------- /* main program */ void main() { #ifdef MODE1T AUXR = 0x04; //BRT work in 1T mode #endif BRT = F38_4KHz; //initial BRT AUXR |= 0x10; //BRT start running WAKE_CLKO = 0x04; //enable BRT clock output while (1); //loop }