;Timerständer Auslesen 6.April 2006 ;-------------------------------------------------------------------- $ INCLUDE (80C552.DEF) ;Definitionen 8052 $ INCLUDE (WORK.DEF) ;Definitionen des Projektes ORG 8000h ;Beginn bei 08000h (für den Kit) _RESET: LJMP START ORG 8400h START: ;-------------------------------------------------------------------- INIT: anl TMOD,#11110001b orl TMOD,#00000001b setb ET0 ;Enable Timer 0 Interrupt clr impulsBbit ;ImpulsBbit wird gesetzt [um diese Werte für später aufzuheben] setb IT0 ;Tranistion activated setb Ex0 ;Enable External 0 Interrupt setb EA ;Global Interrupt Enable/Disable setb TR0 ;Timer 0 Run. When this bit is set Timer 0 is turned on. ;When this bit is cleared Timer 0 is off. ;-------------------------------------------------------------------- main: mov a,30h lcall hex_byte_out mov a,31h lcall hex_byte_out mov a,32h lcall hex_byte_out mov a,33h lcall hex_byte_out ;ausgaben der einzelnen speicheradressen mov a,34h lcall hex_byte_out mov a,35h lcall hex_byte_out mov a,36h lcall hex_byte_out mov a,37h lcall hex_byte_out lcall cr_lf_out ljmp main ;lcall char_in ;testweise char_in ;-------------------------------------------------------------------- org 800Bh ; (((( Timer Interrupt SFR )))) Adresse mov tl0,#10011001b ;Timerlowwerte damit der Timerendwert 64000 ist mov th1,#00011001b ;Timerhighwerte damit der Timerendwert 64000 ist djnz counterl,aus ;Verschachtelter 16 Bit Zähler zum Zählen der Timerüberläufe dec counterh ; ---||--- aus: reti ;Return vom Interrupt ;-------------------------------------------------------------------- org 8003h ; (((( externer Interrupt SFR )))) Adresse jb impulsBbit,impulsb ;a ;nfangs ist kein bit da also zuerst geht er weiter, beim 2.mal springt er mov r0,#30h ;30h in R0 geschoben mov @r0,tl0 ;timerLOWwert von Impuls A auf 30h inc r0 ;31h mov @r0,th0 ;timerHIGHwert von Impuls A auf 31h inc r0 ;32h mov @r0,counterlow ;counterLOWwert in 32h inc r0 ;33h mov @r0,counterhigh ;counterHIGHwert in 33h setb impulsBbit ;ImpulsBbit wird gesetzt [um die Werte von Impuls B für später aufzuheben] jmp int_ende ;überspringe Impuls B falls ImpulsBbit nicht gesetzt impulsb: ;falls ImpulsBbit gesetzt springe hierher mov r0,#34h ;34h in r0 verschoben mov @r0,tl0 ;timerLOWwert von Impuls B auf 34h inc r0 ;35h mov @r0,th0 ;timerHIGHwert von Impuls B auf 35h inc r0 ;36h mov @r0,counterlow ;counterLOWwert in 36h inc r0 ;37h mov @r0,counterhigh ;counterHIGHwert in 37h clr impulsBbit ;ImpulsBbit wird gelöscht [für eventuelles überspringen] int_ende: reti ;Return vom Interrupt end