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?
"why not just straight code"
it doesn't fundamentally solve his problem - that the code doesn't return (for some extremely strange reason, in my view) to main().
your code will have the exact same "problem" - if the code didn't return from his "while (TF1==0);", it wouldn't return from your "while (TF1==0);". thus why i called your line of thoughts "secondary".
at this point, I am inclined to think this is a user (observational) problem.
Erik,
I am beginning to suspect that Ashley is Jack Sprat's mother in law...
TR1 = 1; while(TF1==0);/*Polling mode is used instead of interupt mode*/
will continue, a running timer (0 or 1) will (eventually) set TF to 1.
Erik
Are we sure that we have the full source code?
It was quite some time since I used an 8051 but isn't TF1 auto-cleared if interrupts are used with the timer, while manual-clear without interrupts? So a program that does enable an interrupt handler for this timer but just have an empty ISR would get an interesting competition between the interrupt logic of the chip and the TF1 polling code.
'will continue, a running timer (0 or 1) will (eventually) set TF to 1.'
that's the point of the entire discussion, erik: his code, as well as yours, SHOULD work. but he reported it didn't work.
both of you used exactly the same return mechanism "while (TFn==0);". so if his code, for whatever reason, didn't return from that, your code wouldn't return from that either. using mode 1 vs. 2 does NOT matter at all from that perspective.
jesus! is it really that unreasonable to expect people to have some minimum reading comprehension?
"I am beginning to suspect that Ashley is Jack Sprat's mother in law..."
tammy, as long as i am not YOUR mother or mother in law, i'm ok, :)
Tamir; Ashley is a guy or a shim. He may be Jack Sprat. Bradford
"He may be Jack Sprat."
Or maybe even a Zeusti.
But he/she definitely also hides behind the names Qili, Millwood, and fdan00 on other forums to name a few.
it does work, I have a sneaky suspicion that autoload mode confuses the simulator. Not the first time the simulator has 'simulated' instead of 'replicated'. If it confuses the chip the chip is defective.
why on earth not just see what happens with non-autoload the OP has it right at his fingertips and trying it instead relying on bile from the homewrecker would take, at most 5 minutes.
his code is actual and complete,
You're either deluding yourself, or you're deliberately talking nonsense. I'm sure of that because it's blatantly clear that you have no way of knowing what you just claimed.
The code sent by Erk will work as it functions smoothly in mode 1. After reading the above posts, I think the simulator is designed to function the way it operates. Once it reads the mode, it should load both the registers with the pre-defined values to function in mode 2, but for some reason it doesnt. But the issue is after the roll-over of the TF flag the timer starts again as you step in to execute the next instruction and everything down the lane is stuck.
"After reading the above posts, I think the simulator is designed to function the way it operates. "
tough to think otherwise.
"Once it reads the mode, it should load both the registers with the pre-defined values to function in mode 2, but for some reason it doesnt."
it doesn't because it is not designed to do that, as documented in the datasheet.
the simulator .... it doesn't because it is not designed to do that, as documented in the datasheet.
no simulator is perfect, whatever is documented in the datasheet for the chip may and may not be correctly simulated.
The code sent by Erk will work as it functions smoothly in mode 1. I can appreciate that when the homewrecker nitpicks everything I post you will have doubts trying it. Well, finally we got you going
Too much testosterone there. The homewrecker ain't no girl, trust me on this one. Like lady Gaga :-)