#include "mctools.h" #define FOSC 12000000L //system frequency #define BAUD 9600L //baud-rate #define DLED P2_6 #define ILED P2_7 #define T0_1MS (65536-FOSC/12/1000) static void timer0_isr() __interrupt(1) { static int count=1; if (count--) return; count = 1; ILED = !ILED; return; } void timer0_init() { stc15_timer0_set_sysclk12(); stc15_timer0_set_mode_16bitauto(); TL0 = T0_1MS; // Initial timer value TH0 = T0_1MS>>8; // Initial timer value TF0 = 0; // Clear overflow flag TR0 = 1; // Timer0 start run ET0 = 1; // Enable timer0 interrupt /* AUXR &=0x7F; // T0 in 12T mode TMOD = 0x00; // T0 16-bit-auto-reload TL0 = T0_1MS; // Initial timer value TH0 = T0_1MS>>8; // Initial timer value // TF0 = 0; // Clear overflow flag TR0 = 1; // Timer0 start run ET0 = 1; // Enable timer0 interrupt */ } void main() { ILED=0; timer0_init(); EA=1; while(1); }