/\*------------------------------------------------ MAIN C function b,h,l来对输入字节宽的设置 一个单字节变量时要使用%bd 1.b八位 2.h十六位 3.l三十二位 %d 两个字节变量 int %bd 单字节变量 char %ld 四字节变量 long int %x unsigned int ------------------------------------------------\*/ void main (void) { /\*-------------------------------------- Set serial port for 9600 baud at 11.0592 MHz. Note that we use Timer 1 for the baud rate generator. --------------------------------------\*/ SCON = 0x50; TMOD |= 0x20; TH1 = 0xFA; TR1 = 1; TI = 1;
/\*-------------------------------------- Set Timer0 for 16-bit counter mode. Set the Timer0 Run control bit. --------------------------------------\*/ TMOD = (TMOD & 0xF0) | 0x05; TR0 = 1;
/\*-------------------------------------- Output the value of the counter. As you toggle P3.4, the timer/counter 0 value will increase. --------------------------------------\*/ while (1) {
if(cnt != TL0) { printf ("\rCounter 0 = %2.2bX%2.2bXh", TH0, TL0);//Counter 0 = 0000h led = ! led ; //work LED flash cnt = TL0; } } }