Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help for 8051 counters

Status
Not open for further replies.

Elimathew

Member level 5
Member level 5
Joined
Jun 21, 2011
Messages
88
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
India
Activity points
1,894
im currently syudying 8051 from mazidi, i have a doubt in this particular problem
inside the do while loop as soon as the counter starts the tl0 register is incremented
which is passed as value to the totime function now the current value of value will 197(decimal) it will not show the correct min and sec?
 

how do you calculate that value of variable declared as value is 197 can you explain?
 

intially as the timer is in mode 2 the value tlo(256-60) hence as the counter starts(tr0=1) tlo will be incremented by the first clock pulse and assigned to value
 

The program should be likethis:
....
val=0;
while(1)
{
TR0=1; // start timer0
while(TF0==0); // wait till timer flag 0 overflow
TR0=0; // stop timer0
TF0=0; // clear timer flag 0
val++; // increament val by 1
ToTime(val); // function calculate min & sec and output to P2 and P1
}
 
Last edited:
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top