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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/24/11 05:34
Read: times


 
#183860 - try
Responding to: ???'s previous message



C_seg segment CODE
D_seg segment DATA
B_seg segment bit

rseg D_seg
HalfPeriod2Cnt: ds 1
HalfPeriod1Cnt: ds 1
rseg B_seg
Timer10ms_tickFLAG: ds 1

;-------------------- 

ASEG CODE
  org 0
  ljmp main
  org 01bh
  ljmp timer1isr_handler
;---------------------
rseg C_seg

TIMER1VALUE_10msec equ  56320 ; //(65536-9216)  ,Your timer's input freq is 921600 Hz, 
                                                           ;timer will be incremented 9216 times in 10 millisec timepiece  

Halfperiod2Hz equ  25 ;*10 ms = 250 ms
Halfperiod1Hz equ  50 ;*10 ms = 500 ms
Port_2Hz equ P1.5
Port_1Hz equ P1.6



main:

     
                 	MOV TMOD,#10H       ;timer 1, mode 1 (16-bit)
;  old AGAIN:   
                   MOV TL1,#low(TIMER1VALUE_10msec ) 
                   MOV TH1,#high(TIMER1VALUE_10msec)
                                            
                    SETB TR1            ;start the timer1
                    setb ET1 ;enable Timer 1  interrupt
                    setb EA ; enable common Interrupt Enable
                    mov  HalfPeriod1Cnt,#0 
                    mov  HalfPeriod2Cnt,#0
                   clr  Timer10ms_tickFLAG                 
AGAIN:
;BACK:                   JNB  TF1,BACK       stay till timer rolls over;
;                        CLR TR1             ;stop timer 1
;                        CPL P1.5            ;comp. p1.5 to get hi, lo
;                        CLR TF1             ;clear timer flag 1
;                        SJMP AGAIN          ;reload timer since mode 1
;                                            ;is not auto-reload
          jnb  Timer10ms_tickFLAG, AGAINno10ms
         clr  Timer10ms_tickFLAG
         call Freq2HzHandle
         call SomeOther10msecProc       
AGAINno10ms:
         call SomeOtherUsefullProc
         jmp AGAIN
;-----
Freq2HzHandle:
    inc  HalfPeriod2Cnt
   mov a, HalfPeriod2Cnt
   clr c
   subb a,# Halfperiod2Hz
   jc Freq2Hzret
   mov  HalfPeriod2Cnt,#0
   CPL Port_2Hz
Freq2Hzret:
   ret

SomeOther10msecProc:
       ;-------
      ret
SomeOtherUsefullProc
       ;..................
        ret



timer1isr_handler:
                      push PSW
                      push a
                      clr TR1
                      MOV TL1,#low(TIMER1VALUE_10msec ) 
                      MOV TH1,#high(TIMER1VALUE_10msec)
                      setb TR1
                     ;clr TF1  - not needed flag is autocleared , when ISR enters 
                      setb Timer10ms_tickFLAG
                      
                      inc HalfPeriod1Cnt
                      mov a, HalfPeriod1Cnt
                      clr c
                      subb a,#HalfPeriod1Hz
                      jc timer1isr_end
                      mov  HalfPeriod1Cnt,#0
                     cpl Port_1Hz
timer1isr_end:
                     pop a
                     pop PSW
                     reti


 



List of 42 messages in thread
TopicAuthorDate
Need a little help with frequency            01/01/70 00:00      
   use 89c52            01/01/70 00:00      
   "formulae"            01/01/70 00:00      
   How to post legible source code - and text            01/01/70 00:00      
      Legible source code            01/01/70 00:00      
         Not the whole message!            01/01/70 00:00      
            Thanks Andy got little messed up            01/01/70 00:00      
               Already answered            01/01/70 00:00      
                  Still not understanding isr with tick            01/01/70 00:00      
                     use may use this code            01/01/70 00:00      
                        Thanks for time            01/01/70 00:00      
                        Rewrote Source Code for Metalink Assembler            01/01/70 00:00      
                           keil assembler            01/01/70 00:00      
                           No need for picture            01/01/70 00:00      
                     try            01/01/70 00:00      
                        the code above is a typical illustration of ...            01/01/70 00:00      
                           You are right            01/01/70 00:00      
                              never too old            01/01/70 00:00      
                                 Never too late to pick up a new trick            01/01/70 00:00      
                                    One good trick ...            01/01/70 00:00      
                                 Score -1            01/01/70 00:00      
                                    Learn one before Jumping head            01/01/70 00:00      
                                       Learning Assembler First            01/01/70 00:00      
                                          I wholehardely concur.            01/01/70 00:00      
                        Thanks also you for your time            01/01/70 00:00      
   Here's something to try ...            01/01/70 00:00      
   One suggession for higher frequency            01/01/70 00:00      
      Remember no fractional part for            01/01/70 00:00      
         Precise frequency            01/01/70 00:00      
      I did not know that            01/01/70 00:00      
         89c2051            01/01/70 00:00      
            When you wrote code            01/01/70 00:00      
               You normally always need to test - but may not need to debug            01/01/70 00:00      
               it was example            01/01/70 00:00      
                  Ok then if I            01/01/70 00:00      
                     try            01/01/70 00:00      
                     depends            01/01/70 00:00      
                     Testing Code            01/01/70 00:00      
                        In short            01/01/70 00:00      
                           someone said it better            01/01/70 00:00      
                              "Proven Product" Syndrome            01/01/70 00:00      
                     Did you ever look at that MIDE51 I previously mentioned?            01/01/70 00:00      

Back to Subject List