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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/25/11 00:43
Read: times


 
#183864 - Thanks for time
Responding to: ???'s previous message
Maunik Choksi said:
        .equ    OUTPIN,P2.1
        .equ    basecount,021h

          .org  0000h
          SJMP  MAIN

          .org  000bh           ;Use timer0
          LJMP  TIMER_ROUT

          .org  0070h

MAIN:     MOV   SP,#050H

          MOV   TMOD,#01H       ;initialise timer 0 in 16 bit mode

          mov   IP,#02h         ;give priority to timer0

          mov   TH0,#0ech       ;5ms timer count loaded
          mov   TL0,#078h       ;for 12 Mhz crystal

          ;The formula for deciding count is like
          ;(65535 - 5000) = 60535 here 5000 count for 5ms timer
          ;if you want to generate 1 ms timer then your formula should be
          ;(65525 - 1000) = 64535 and so on.
          ;So here we get count for 5ms timer = 60535D = EC78H =TH0TL0

          setb  TR0             ;turns on timer0
main1:
          MOV   IE,#082H        ;1000 0010 Enables timer0 interrupt

          sjmp  main1

TIMER_ROUT:

;After Every 5ms time the timer interrupt jumps here

          mov   TH0,#0ech       ;Reload timer count
          mov   TL0,#078h

          inc   basecount
          mov   a,basecount
          cjne  a,#50,skipchangestatus  

          cpl   OUTPIN          ;after every 50 * 5 = 250 ms compliment the OutputPin status
                                ;So you get 2 low 2 high output status in 1 sec i.e 2 Hz freq.
          mov   basecount,#0    ;reset the base count

skipchangestatus:
          reti                  ;return from timer interrupt



Hi Maynik:

Thanks for giving me example of the 2 Hz code.

Best regards,

Ralph Sac

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