We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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, typicaly timers are clocked with 1/12 of OSC periods. So in the best case your while loop (TL0<=10) pause will be for time of ten commands' execution. So why do you thing it does not work? Maybe it works but pause is very short. Good days!
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 !!!