I'm trying to pause at while (TL0 <= 10) {} until I get a count of 10. When I run the program, the program doesn't pause at while (TL0 <= 10) {}. It's like the while is false. Can any one see something I don't? // Setup TH0 Timer0 for 16-bit counter mode TMOD = (TMOD & 0xF0) | 0x05; //Set the counter0 Run control bit. TR0 = 1; while (1) { //reset Tiimer0 (counter) TL0 = 0; // Toggle P3.4 increment the count while (TL0 <= 10) {} //The rest of the code }
Hi Oleg, you could be right, however in this case you didn't realize that the timer 0 was clocked not by oscillator but by toggling pin T0 (P3.4). "When I run the program, the program doesn't pause at while (TL0 <= 10) {}." My question: Does the program jump over "while condition" 1st - right after reset or 2nd - after "first touching" the pin T0? I guess it is the 2nd case, am I right? In my opinion the most important thing here is debouncing contact used for toggling T0 !!!