??? 04/04/10 14:33 Read: times |
#174827 - P89V51RD2 Timing |
Hi, I want to trigger some code every 1 second using the timer0 in mode 2. I am driving the chip at 18.432MHz. Here is my code so far:
void timer0 (void) interrupt 1 using 1 { if (++ cycle == 10000) { <code to be triggered every 1 second> cycle = 0; } } void main() { TH0 = ??; TL0 = ??; TMOD = TMOD | 0x02; TR0 = 1; ET0 = 1; while (1) { } } Could someone please advise what values I need to assign to TH0 and TL0 (I think they are the same in mode 2?), and also how I would set up a Wait function using Timer 1, e.g. void Wait (unsigned char t) { unsigned char c; for (c=0;c<t;c++) { TH0 = ??; TL0 = ??; TR0 = 1; TF0 = 0; while (TF0 == 0); TR0 = 0; } } How do I set the mode for the Wait function accordingly? And how I calculate what to put in TH0 and TL0? e.g. so that Wait(10) pauses for 100ms. Many thanks for your help. |
Topic | Author | Date |
P89V51RD2 Timing | 01/01/70 00:00 | |
FAQ? | 01/01/70 00:00 | |
yes, but | 01/01/70 00:00 | |
Limit to max period length of a timer | 01/01/70 00:00 | |
I wouldn't just max out the timer![]() | 01/01/70 00:00 | |
User manual? | 01/01/70 00:00 | |
User manual for P89V51 | 01/01/70 00:00 |