I use Keil sometimes and while using a timer in autoload mode, the TH0 is loaded with the calculated value but TL0 starts incrementing from 00 instead of the calculated value F0.Am I missing something while using or configuring the keil simulator?
I am simply amazed how many people who are supposed to be savvy at least with computers, fail to grasp the advantage of using "copy-paste" (but they apparently use it with success in their homework!) and re-type their "code". Stunning.
This is one of the better lines:
while(TF0==)
I have to assume that the while loop should run until TFD becomes NULL.
"The program below"
that's a great piece of code.
keep up the good work!
The program below is for generating square wave of some delay. I have taken F0 as eg to
check for small duration. When I run the program in step mode, the TL0 increments directly
to F3 and then the timer stops in autoload mode.The same set of instructions function in mode 1 I use keil Uvision 2.
#include <reg51.h>
void delay(); sbit mybit = P1^5; main(); { while(1) { mybit = mybit^1; delay(); } }
void delay() { TMOD = 0x02; TH0 = 0xF0; TL0 = 0xF0; TRO = 1 while(TF0==) TR0 = 0; TF0 = 0; }
Most likely you're missing the fact that you are supposed to load the initial count into T0L the first time round if you want the first interval to be the same length as all the later ones. Only after reaching roll-over the first time does the value in T0H get used as a reload value.