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 }
it would be a good idea to add TH0 and TH1 to the code, there is no 'automatic reset' when settong TR, that would kill 99% of the timer code out there. Erik
Hi, it would be a good idea to add TH0 and TH1 to the code, there is no 'automatic reset' ... Here they use while_loop based on TL0 (low byte of the timer in 16-bit mode) so it is not need to set TH0. The increasing of TL0 is not affected by value of TH0 because ticks come from OSC/12 to TL0 and then to TH0. As result TL0 always increases 0->255->... as long as TR0 is set.