#include <reg51.h> #include <stdio.h> extern void MSDelay(unsigned int); extern void SerialTx(signed int); void main (void) { int x,y; SerialTx(-3); TMOD=0xAD; //use Timer 1 and Timer 0, mode 2 TH0=0x00; // One half of the period is 100 µs. 100/1.085 µs = 92, and TH0 = 256 - 92 = 164 or A4H( for interrpt) TL0=0x00; //IE=0x82; //enable interrupt for timer 0 //x=TH0; //x=x<<8; //x=x+TL0;
while(1)
{ if( P1^0==0) { TR0=1; TI=1;
x=TH0; x=x<<8; x=x+TL0; printf("The Timer 0 is ON. And The Value is%x\n"); MSDelay(60); } else {
TI=1; printf("The Timer 0 is OFF. \n"); MSDelay(60); } //TI=1; //printf("%x",x); //MSDelay(60); } }
Going for high-score for confused post?
By the way - how good is it when a source code line and a comment doesn't seem to agree with each other? Which of them are then expected to be correct?
TH0=0x00; // One half of the period is 100 µs. 100/1.085 µs = 92, and TH0 = 256 - 92 = 164 or A4H( for interrpt)
0x00 and 0xa4 doesn't seem to represent the same value...