| Author |
Message |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
26 Apr 2005 4:57 0.2m Sec |
|
|
|
|
Hi,
Anyone know how to calculate/get the -200 = 0.2ms?? Is it the -200 is the dec number??
TMOD = 0x02; /* TIMER0 at Mode 2 */
TH0 = -200; /* 0.2ms (200us) */
TL0 = -200;
TR0 = 1; /* start timer */
Thank You.
|
|
| Back to top |
|
 |
IanP
Joined: 05 Oct 2004 Posts: 6490 Helped: 1542 Location: West Coast
|
26 Apr 2005 5:21 Re: 0.2m Sec |
|
|
|
|
Timer0(1) in MODE2 is a 8-bit counter (TL0(1), fed from clock/12) and at 11.0952MHz clock you need ≈184d reload value in TH0(1) to achieve 0.2ms ..
Last edited by IanP on 26 Apr 2005 8:13; edited 1 time in total |
|
| Back to top |
|
 |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
26 Apr 2005 5:45 Re: 0.2m Sec |
|
|
|
|
Hi,
What is ~184d reload?? how to calculate the value? -200??
Thank You..
|
|
| Back to top |
|
 |
IanP
Joined: 05 Oct 2004 Posts: 6490 Helped: 1542 Location: West Coast
|
26 Apr 2005 6:12 Re: 0.2m Sec |
|
|
|
|
In assembly language sometimes negative values, such as -200, are represented by FF38 (65536-200)..
Reload value of 184d is calculated as follows:
11059200/12=921600 - clock frequency to TIMER0 in MODE2
1/(921600*X)=0.0002s
X=184.32 ≈ 184d
|
|
| Back to top |
|
 |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
26 Apr 2005 7:16 Re: 0.2m Sec |
|
|
|
|
Hi
Reload value of 184d is calculated as follows:
| Quote: |
11059200/12=921600 - clock frequency to TIMER0 in MODE2
1/(921600*X)=0.0002s
X=184.32 ≈ 184d |
How do you know is 0.2ms?? Can you explain mare what is X value for what??
Thank You
|
|
| Back to top |
|
 |
IanP
Joined: 05 Oct 2004 Posts: 6490 Helped: 1542 Location: West Coast
|
26 Apr 2005 7:28 Re: 0.2m Sec |
|
|
|
|
X is just a sumbol used to solve an equasion; you can use A, B, C or Z, but it is still the reload value for TH1.
If the input pulse to TIMER0 equals to 1/ 921600 = 1.085µs then if you multiply this value by 184 the resultant time will be 1.085µs * 184 ≈ 0.2ms
|
|
| Back to top |
|
 |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
26 Apr 2005 7:49 Re: 0.2m Sec |
|
|
|
|
Hi,
I still not understand the "reload value for TH1", the mode 2 have related to T1??
Thanks..
|
|
| Back to top |
|
 |
IanP
Joined: 05 Oct 2004 Posts: 6490 Helped: 1542 Location: West Coast
|
26 Apr 2005 7:58 Re: 0.2m Sec |
|
|
|
|
Both timers, TIMER0 and TIMER1 are identical in modes 0, 1 and 2;
So for Timer0 the reload value will be for TL0 and TH0,
for TIMER1: TL1 and TH1 ..
Sorry for confusion ..
|
|
| Back to top |
|
 |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
26 Apr 2005 8:04 Re: 0.2m Sec |
|
|
|
|
Hi,
Nvm, so..
TMOD = 0x02; /* TIMER0 at Mode 2 */
TH0 = -200; /* 0.2ms (200us) */
TL0 = -200;
TR0 = 1; /* start timer */
Now i setting is Timer0, so the you mean reload value is for TH0 is it??
Thanks..
|
|
| Back to top |
|
 |
IanP
Joined: 05 Oct 2004 Posts: 6490 Helped: 1542 Location: West Coast
|
26 Apr 2005 8:10 Re: 0.2m Sec |
|
|
|
|
Initially you have to reload both TL0 and TH0 and after first overflow fromTL0 it will set TF0 and also reloads TL0 with TH0 ..
And the reload value of TH0 remains unchanged ..
|
|
| Back to top |
|
 |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
26 Apr 2005 8:17 Re: 0.2m Sec |
|
|
|
|
Ya.. Is true the TH0 still remains unchanged at 0x38 because we already set it. So how about the 184 value?? for what??
Thanks..
|
|
| Back to top |
|
 |
IanP
Joined: 05 Oct 2004 Posts: 6490 Helped: 1542 Location: West Coast
|
26 Apr 2005 8:27 Re: 0.2m Sec |
|
|
|
|
200 is the value for clock frequency of 12MHz;
184 is the value for clock frequency of 11,0592MHz ..
|
|
| Back to top |
|
 |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
26 Apr 2005 8:39 Re: 0.2m Sec |
|
|
|
|
Oh.........,
Now i already understand, very thk u!!
Why use 11,0592MHz standard they use 12MHz is it??
Thank
|
|
| Back to top |
|
 |
IanP
Joined: 05 Oct 2004 Posts: 6490 Helped: 1542 Location: West Coast
|
26 Apr 2005 8:43 Re: 0.2m Sec |
|
|
|
|
| It look like that, as the input frequency to TIMER0 will be 1MHz (1µs) @ 12MHz crystal .. multiplied by 200 gives you 200µs ..
|
|
| Back to top |
|
 |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
26 Apr 2005 9:31 Re: 0.2m Sec |
|
|
|
|
Hi,
Thank You vary much now i really understand already.
Do you have any web side, or reference book for explaining this type of code (timer, counter, interrupt, overflow and so on) and give some simple code... ??
Thank You..
|
|
| Back to top |
|
 |
IanP
Joined: 05 Oct 2004 Posts: 6490 Helped: 1542 Location: West Coast
|
26 Apr 2005 10:33 Re: 0.2m Sec |
|
|
|
|
What I use as reference is a hard copy of "80C51-Based 8-bit Microcontrollers - Data Handbook" from Philips Semiconductors .. It is about 1400 pages ..
I'm not sure if you can download something like this from the net ..
|
|
| Back to top |
|
 |
Google AdSense

|
26 Apr 2005 10:33 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
26 Apr 2005 13:01 Re: 0.2m Sec |
|
|
|
|
Hi,
So, do you have any simple sample program for you own experience because now i like studying theory and no have practice... hai.. very hard.... ...
Thanks...
Added after 2 hours 5 minutes:
| IanP wrote: |
What I use as reference is a hard copy of "80C51-Based 8-bit Microcontrollers - Data Handbook" from Philips Semiconductors .. It is about 1400 pages ..
I'm not sure if you can download something like this from the net .. |
Hi,
I already try to search for this data handbook but still get it. Inside the book have alot of sample is it?? Can you send it to me?? I hope this book can help me.... ...
Thank You
|
|
| Back to top |
|
 |
silvio
Joined: 31 Dec 2001 Posts: 801 Helped: 90
|
26 Apr 2005 17:27 Re: 0.2m Sec |
|
|
|
|
| Help wrote: |
Hi,
So, do you have any simple sample program for you own experience because now i like studying theory and no have practice... hai.. very hard.... ...
Thanks...
Added after 2 hours 5 minutes:
| IanP wrote: |
What I use as reference is a hard copy of "80C51-Based 8-bit Microcontrollers - Data Handbook" from Philips Semiconductors .. It is about 1400 pages ..
I'm not sure if you can download something like this from the net .. |
Hi,
I already try to search for this data handbook but still get it. Inside the book have alot of sample is it?? Can you send it to me?? I hope this book can help me.... ...
Thank You |
Straight from Philips :
http://www.semiconductors.philips.com/acrobat_download/various/80C51_FAM_ARCH_1.pdf
http://www.semiconductors.philips.com/acrobat_download/various/80C51_FAM_HARDWARE_1.pdf
http://www.semiconductors.philips.com/acrobat_download/various/80C51_FAM_PROG_GUIDE_1.pdf
or you can get the genuine Intel MCS(R) 51 Microcontroller Family User's Manual
from here:
http://www.intel.com/design/mcs51/manuals/272383.htm
If you have spare time you can take a look at the all MCS51 INTEL's documentation:
http://www.intel.com/design/mcs51/docs_mcs51.htm
|
|
| Back to top |
|
 |
wolfheart_2001
Joined: 17 Mar 2005 Posts: 92 Helped: 9
|
26 Apr 2005 18:20 Re: 0.2m Sec |
|
|
|
|
MCU operates with cycles , each cycle equal to clock_freq/12(12 clock pulses for one cycle)
if u use a 12MHZ crystal then each cycle equal (1/12000000 )*12=1us
the timer increment its value at each cycle.
since the timer increment not decrement then u use the 2's complement of 200( -200 will be intepreted to be the 2's comlement of 200), so after 200 increment for every 200 cycle and each cycle equal 1us(12MHZ crystal)
then u get a delay of 200us or .2ms.
but remember to enable the dedicted interrupt and remember the to take care how the int handler wil work.
|
|
| Back to top |
|
 |
Help
Joined: 15 Feb 2005 Posts: 560 Helped: 4
|
27 Apr 2005 2:46 Re: 0.2m Sec |
|
|
|
|
Hi silvio & wolfheart_2001,
Do you have any idea where can i get the information that can teach me how to write a C-code in 8051 application note??
Thanks...
|
|
| Back to top |
|
 |