# Include <reg52.h> # define uchar unsigned char # define uint unsigned int uint I; void main () {I = 0; EA = 1; // enable the total interrupt TMOD = 0x01; // use the timer T0's working method 1 ET0 = 1; // The timer T0 interrupt allows TH0 = (65536-50000)/256; // assign TL0 = (65536-50000) % 256 to the high 8-bit timer T0; // assign TR0 = 1 to the low 8-bit timer T0; // start the timer T0 P0 = 0xff; while (1); // infinite loop wait interrupt} void Time0 (void) interrupt 1 // "interrupt" declares that the function is an interrupt service function, 1 indicates the interrupt Number of the timer T0 {I ++; if (I = 40) {P0 = ~ P0; I = 0;} TH0 = (65536-50000)/256; TL0 = (65536-50000) % 256 ;} # include <reg52.h> # define uchar unsigned char # define uint unsigned intuint I; void main () {I = 0; EA = 1; // enable the total interrupt TMOD = 0x01; // use the timer T0's working method 1ET0 = 1; // The timer T0 interrupt allows TH0 = (65536-50000)/256; // assign TL0 = (65536-50000) % 256 to the high 8-bit timer T0; // assign TR0 = 1 to the low 8-bit timer T0; // start the timer T0P0 = 0xff; while (1); // infinite loop wait interrupt} void Time0 (void) interrupt 1 // "interrupt" declares the function as an interrupt service function, 1 indicates the interrupt Number of the timer T0 {I ++; I F (I = 40) {P0 = ~ P0; I = 0;} TH0 = (65536-50000)/256; TL0 = (65536-50000) % 256 ;}