??? 05/26/06 09:01 Read: times |
#117131 - code finished, but small error Responding to: ???'s previous message |
hello!
first i want to thank all of you who posted me and helped me reaching my goal. i've written my source code now but i have a small problem with the output. i built the difference between the oldest and the old capture when a new capture happens. the difference should be the period T of my signal as i am always triggering on the falling edge of my square signal. here is my code: as we are programming in 3 independent files(ASM;DEF;INT) i have to send all 3 files: firstly the Assembler file: IMPORTANT NOTICE: OLD=ALT NEW=NEU $ INCLUDE (80C552.DEF) ;Definitionen 8052 $ INCLUDE (WORK.DEF) ;Definitionen des Projektes ORG 8000h ;Beginn bei 08000h (für den Kit) _RESET: LJMP START $ INCLUDE (WORK.INT) ORG 8400h START: mov sp,#stack-001h ;-------------------------------------------------------------------- INIT: ;timer 2 initialisierungen mov TM2CON,#00000001b mov CTCON,#00000010b mov TM2IR,#00000001b mov IEN1,#00000001b mov r2,#3 clr f0 setb ea ;------------------------------------------------------------- main: jnb f0,main clr ea ;_______________________________________________________________ ;(AUSGABEPROGRAMM ZUM TESTEN DES ERGEBNISSES) mov dptr,#zeichen0 ;___ lcall string_out ;| mov a,cth0neu ;| lcall hex_byte_out ;cth0neu out | lcall cr_lf_out ; |new ; |capture mov dptr,#zeichen1 ; |values lcall string_out ; | mov a,ctl0neu ; | lcall hex_byte_out ;ctl0neu out | lcall cr_lf_out ;"""" ;............................................................ mov dptr,#zeichen2 ;___ lcall string_out ; | mov a,cth0alt ;cth0alt out | lcall hex_byte_out ; | lcall cr_lf_out ; old mov dptr,#zeichen3 ; |capture lcall string_out ; |values mov a,ctl0alt ;ctl0alt out ; | lcall hex_byte_out ; | lcall cr_lf_out ;""" ;.............(subtraction: )................. clr cy mov a,ctl0alt ;+ subb a,ctl0neu ;| mov erg_lo,a ;+ mov a,cth0alt ;+ subb a,cth0neu ;| mov erg_hi,a ;+ mov dptr,#zeichen6 lcall string_out lcall cr_lf_out mov dptr,#zeichen4 lcall string_out ;....................... mov a,erg_lo ;+ lcall hex_byte_out ;+ lcall cr_lf_out mov dptr,#zeichen5 lcall string_out mov a,erg_hi ;+ lcall hex_byte_out ;+ lcall cr_lf_out lcall char_in ;................... lcall cr_lf_out lcall cr_lf_out mov r2,#03 clr f0 setb ea ljmp main zeichen0: DB 'Value High NEU ist: ',80h zeichen1: DB 'Value Low NEU ist: ',80h zeichen2: DB 'Value High ALT ist: ',80h zeichen3: DB 'Value Low ALT ist:',80h zeichen4: DB 'Ergebnis1 (=ergebnis low) ist: ',80h zeichen5: DB 'Ergebnis2 (=ergebnis high) ist: ',80h zeichen6: DB '_____________________________________' end -------------------------------------------------- ORG 08033h _TF2_EXF2: LJMP JR1_T1 ORG 08073h ljmp JIE0 JR1_T1: mov cth0alt,cth0neu mov ctl0alt,ctl0neu mov cth0neu,cth0 mov ctl0neu,ctl0 djnz r2,aus setb f0 aus: reti ------------------------------------------------------------- ctl0alt data 3Ah ctl0neu data 3Bh cth0alt data 3Ch cth0neu data 3Dh erg_lo data 30h erg_hi data 31h |