标题: STC12C20xx单片机EEROM测试程序 [打印本页]

作者: gqzjl    时间: 2021-2-6 14:47
标题: STC12C20xx单片机EEROM测试程序
先上程序
  1. #include "reg51.h"

  2. //-----------------------------------------------

  3. /* define constants */
  4. #define FOSC 11059200L
  5. //#define MODE1T                      //Timer clock mode, comment this line is 12T mode, uncomment is 1T mode

  6. #ifdef MODE1T
  7. #define F38_4KHz (256-FOSC/2/38400)    //38.4KHz frequency calculation method of 1T mode
  8. #else
  9. #define F38_4KHz (256-FOSC/2/12/38400) //38.4KHz frequency calculation method of 12T mode
  10. #endif

  11. /* define SFR */
  12. sfr AUXR      = 0x8e;               //Auxiliary register
  13. sfr WAKE_CLKO = 0x8f;               //wakeup and clock output control register
  14. sbit T1CLKO   = P1^1;               //timer1 clock output pin

  15. //-----------------------------------------------

  16. /* main program */
  17. void main()
  18. {
  19. #ifdef MODE1T
  20.     AUXR = 0x40;                    //timer1 work in 1T mode
  21. #endif
  22.     TMOD = 0x20;                    //set timer1 as mode2 (8-bit auto-reload)
  23.     TL1 = F38_4KHz;                 //initial timer1
  24.     TH1 = F38_4KHz;                 //initial timer1
  25.     TR1 = 1;                        //timer1 start running
  26.     WAKE_CLKO = 0x02;               //enable timer1 clock output

  27.     while (1);                      //loop
  28. }
复制代码








欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1