??? 08/22/05 16:25 Read: times |
#99839 - Timer miscounts? |
hey hey
I've created a small routine to test teh timer interrupt, but somehow it does not work as I wish. The routine works, led flash on P1 and with a steady interval the caracter C erupts out of Hyper Terminal, the only problem is the caracter should erupt every 5 secons acording to tutorial calculations, only it takes some 13 seconds.... I think the problem shoud be somewhere in the intrrupt riming but I can't find what goes wrong this is the code ; Timer interrupt X-tal 11.0592 MHz AT89S8252 processor ;set serial receive for 19200/8/n/1 #include 8051.H .org 0000H sjmp Main .org 0060H Main acall Init mov P1, #0FH run inc R1 ; simple LED flash routine mov P1, R1 mov R4, #255 djnz R4, $ mov R4, #255 djnz R4, $ sjmp run .end Init mov TMOD, #21h ; Timer 1 in Auto-reload mode, Timer 0 in 16 bit mode mov TH1, #253 ; load T1 for 19200 baud mov TH0, #48h ; set for 20 ms mov TL0, #00 ; mov IE, #00h ; reset intterupts mov PCON, #80h ; set SMOD for 19200 baud mov SCON, #50h ; serial mode 1, REN=1 setb TR1 ; start timer setb TR0 setb EA ; enable interrups setb ET0 ; enable T0 mov R1, #00 mov P1, #00 mov R3, #250 ret ; return SEND clr TI ; Be sure the bit is initially clear mov SBUF, A ; send character jnb TI, $ ; Pause until the TI bit is set. ret ; return ;---------Interrupt Routines---------- .org 000Bh ; T0 interrupt clr TF0 clr TR0 djnz R3, EXIT mov TH0, #48h ; set for 20 ms mov TL0, #00 ; setb TR0 mov A, #'C' acall SEND mov R3, #250 ; for 5 sec interval reti EXIT mov TH0, #48h ; set for 20 ms mov TL0, #00 ; setb TR0 reti thanks ahead maybe you can solve the problem Regards Jeroen |
Topic | Author | Date |
Timer miscounts? | 01/01/70 00:00 | |
Counter counts upwards | 01/01/70 00:00 | |
solved | 01/01/70 00:00 | |
More problems | 01/01/70 00:00 | |
further optimisation | 01/01/70 00:00 | |
Right here: | 01/01/70 00:00 | |
Bible time... | 01/01/70 00:00 | |
you are right | 01/01/70 00:00 | |
Thinking time | 01/01/70 00:00 | |
how precise "bibles" are | 01/01/70 00:00 | |
Actually, PSW IS affected | 01/01/70 00:00 | |
bible time again and again | 01/01/70 00:00 | |
Not there??????? | 01/01/70 00:00 | |
wilbers.asm updates | 01/01/70 00:00 | |
The shame of it all! | 01/01/70 00:00 | |
I am sorry | 01/01/70 00:00 | |
old farts make mistakes too | 01/01/70 00:00 | |
No offense taken | 01/01/70 00:00 | |
wow what a replies![]() | 01/01/70 00:00 |