Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/26/07 02:54
Read: times


 
#133679 - Counting 1 second, its my code correct?
Hi, Im new at microcontrolers and asm programming, i need help to see if my code is correct and will count really 1 second, im using ATMEL 89S52 and 12mhz Crystal...

TICKS EQU 07Fh

RESET_VALUE EQU 15535 ;valor de reset do timer

;Inicio do programa
ORG 0000h
LJMP MAIN

ORG 001Bh ;Interrupção Timer1
CLR TR1 ;Desativa Timer1
MOV TH1,#HIGH RESET_VALUE-5
MOV TL1,#LOW RESET_VALUE-5
SETB TR1 ;Reativa Timer1
DJNZ TICKS,EXIT_RTC ;Salta se TICKS for diferente de zero (ou seja, não se passou 1 seg.)
MOV TICKS,#20
CPL A ;Inverte bits do acumulador
MOV P0,A
MOV P1,A
MOV P2,A
MOV P3,A
EXIT_RTC:
RETI

MAIN:
MOV A,#0 ;Zera acumulador
MOV TICKS,#20
MOV TH1,#HIGH RESET_VALUE-5
MOV TL1,#LOW RESET_VALUE-5
MOV TMOD,#10h ;Config. Timer 1 para modo 16bit
SETB EA ;Inicializa interrupções
SETB ET1 ;Inicializa interrupção do Timer1
SETB TR1 ;Ativa Timer1
JMP $
END

this program should just turn on and off leds on all P ports second at second. I need to know if i can build a clock using this, and if it will be precise. Im waiting your answer. Thanks.

List of 9 messages in thread
TopicAuthorDate
Counting 1 second, its my code correct?            01/01/70 00:00      
   Code works. Total loop time = 1.025 secs            01/01/70 00:00      
      i think already 15535            01/01/70 00:00      
         JSIM.EXE stop watch gives loop time            01/01/70 00:00      
            JSIM            01/01/70 00:00      
               Probably the Keil will work perfectly...            01/01/70 00:00      
                  I tried Keil            01/01/70 00:00      
   latency compensation            01/01/70 00:00      
   double post            01/01/70 00:00      

Back to Subject List