| ??? 12/04/01 19:28 Read: times |
#17257 - RE: Please check my program codes |
Hi George,
It's true that timer 2 is useless in his code. At least until reveals something else. But what has to do with his code setting TCON.1 (External Interrupt 0 edge flag). Setting TCON.4 is the same thing as SETB TR0 placed four lines bellow in the code. It wouldn't be wise to took off the initialised instructions from the main loop ?. In order to be executed only once at start up. I mean: MOV TCON,#00010010B MOV TMOD,#00000010B MOV TL0,#3CH MOV TH0,#00H On the other hand, why keeping MOV TL0,#3CH and MOV TH0,#00H after CLR TF0 ? Since the timer was configured to work in mode 2, 8 bit autoreload, I see no reason to load the TH0 at every pass inside loop. The reload leaves TH0 unchanged (initialised at start up). When Timer0 overflows and TF0 is set, TL0 is loaded with the contents of TH0 (in our case 00H). After CLR TF0 you reload software TL0 with 3CH. Why ? Just counting from 3CH to FFH as units increment ? But you can fine adjust the 1 min delay from either R0 or R1 values. In the "timer" function, the register is incremented every machine cycle. Thus the time spend in all DJNZ loops is 4000 X (256 - (TH0 value)) machine cycle. Obvious if you leave alone TL0 during loops. With 12MHZ oscillator and standard 8051 machine cycle of 12 oscillator periods and TH0 = 00H, that means 1 second !!. It's that what he really see on P1.7 ? A LED flashing at 1 second period. Regards, Silviu |
| Topic | Author | Date |
| Please check my program codes | 01/01/70 00:00 | |
| RE: Please check my program codes | 01/01/70 00:00 | |
| RE: Please check my program codes | 01/01/70 00:00 | |
| RE: Please check my program codes | 01/01/70 00:00 | |
| RE: Please check my program codes | 01/01/70 00:00 | |
| RE: Please check my program codes- Steve | 01/01/70 00:00 | |
| RE: Please check my program codes- Steve | 01/01/70 00:00 | |
| RE: Please check my program codes- Steve | 01/01/70 00:00 | |
| Ps Check program codes-George & Silviu | 01/01/70 00:00 | |
| RE: Ps Check program codes-George & Silviu | 01/01/70 00:00 | |
| RE: Ps Check program codes-George & Silviu | 01/01/70 00:00 | |
| RE: Ps Check program codes-George & Silviu | 01/01/70 00:00 | |
| RE: Ps Check program codes-George & Silviu | 01/01/70 00:00 | |
| RE: Ps Check program codes-Silviu | 01/01/70 00:00 | |
| RE: Ps Check program codes-Erik | 01/01/70 00:00 | |
RE: Please check my program codes | 01/01/70 00:00 |



