| ??? 03/12/01 20:57 Read: times |
#9957 - RE: Why changing th0/tl0, time not change ? |
You forgot a TCOUNT variable. Your code to change the P1.5 was very complicated. Just use cPL P1.5.
Then you should better to take into account the execution time of body of ISR so try MOV TL0,#TIL-tau, where tau is equal of the execution time. Below is the corrected example. George TCOUNT EQU 040H ;This is an address in IRAM ALARM EQU 000H ;This is NOT an address of BIT memory TIH EQU 000H TIL EQU 0FFH ORG 0000H JMP MAIN ORG 000BH T0_INTR: DJNZ TCOUNT,T0_EXIT MOV TCOUNT,#20 ;Set TCOUNT to 20 to wait for 1 second CLR TR0 ;Turn timer 0 off MOV TL0,#TIL-tau MOV TH0,#TIH SETB TR0 ;Turn timer 0 on CPL P1.5 T0_EXIT: RETI ; MAIN: MOV TMOD,#001H ;Set timer 0 to 16-bit mode MOV TH0,#TIH ;Initialize TH0 to overflow every .05 seconds MOV TL0,#TIL ;Initialize TL0 to overflow every .05 seconds SETB ET0 ;Enable timer interrupt 0 SETB EA ;Enable all interrupts MOV TCOUNT,#20 ;Set TCOUNT to 20 to wait for 1 second CLR P1.5 SETB TR0 ;Turn timer 0 on JMP $ |
| Topic | Author | Date |
| Why changing th0/tl0, time not change ? | 01/01/70 00:00 | |
| RE: Why changing th0/tl0, time not change ? | 01/01/70 00:00 | |
| RE: Why changing th0/tl0, time not change ? | 01/01/70 00:00 | |
RE: Why changing th0/tl0, time not change ? | 01/01/70 00:00 |



