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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Ralph Sac
09/16/11 21:32
Read: 1311 times

#183780 - Need a little help with frequency

This is a program I took out of a text book on 8051 microcontroller. It is a program which creates square wave on

P1.5 using a crystal 11.0592 Mhz and frequency is around 26 Hz. My question is what is the formula to pick your own

desired frequency for this circuit? I would like make the frequency 2hz instead the original 26 Hz. But do not

understand how 26 Hz frequency is picked for TL1 and TH1. I been member of website since 2003 and usually don't ask

for help, but maybe my gray matter is not as good since I am now in my 60's still trying to learn this 8051 chip. Any

way here is text example.

MOV TMOD,#10H ;timer 1, mode 1 (16-bit)
AGAIN: MOV TL1,#34H ;TL1=34H,low byte of timer
MOV TH1,#76H ;TH1=76H,HI byte
;(7634H=timer value)
SETB TR1 ;start the timer1
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

All I am trying to do is make small change to this program so it outputs 2Hz square wave on p1.5 using TL1 and TH1.

But I want to know the formula to do this so I change the frequency as I experiment with different frequencies with

the 8051 chip. Can any one give me some help on how to do this. And steps I would use to do this? I understand the

sequence of the program, but not the part of how pick the desired frequency. Thanks in advance for any help. It was

lot easier for me to understand digital and analog then this 8051 microcontroller? With a 555timer I could get this

frequency with few active and passive components. The chip I will use 89c2051 flash as it's almost as small as 555timer chip. I could also have used cd4049 to create this frequency.

Best regards,

Ralph Sac

List of 42 messages in thread
Need a little help with frequency      Ralph Sac      09/16/11 21:32      
   use 89c52      Maunik Choksi      09/16/11 23:00      
   "formulae"      Stefan KAnev      09/16/11 23:34      
   How to post legible source code - and text      Andy Neil      09/17/11 10:43      
      Legible source code      Ralph Sac      09/17/11 16:09      
         Not the whole message!      Andy Neil      09/17/11 16:16      
            Thanks Andy got little messed up      Ralph Sac      09/17/11 17:00      
               Already answered      Per Westermark      09/17/11 18:43      
                  Still not understanding isr with tick      Ralph Sac      09/23/11 21:33      
                     use may use this code      Maunik Choksi      09/23/11 23:19      
                        Thanks for time      Ralph Sac      09/24/11 18:43      
                        Rewrote Source Code for Metalink Assembler      Ralph Sac      10/20/11 18:36      
                           keil assembler      Maunik Choksi      10/20/11 23:25      
                           No need for picture      Maunik Choksi      10/21/11 07:36      
                     try      Stefan KAnev      09/23/11 23:34      
                        the code above is a typical illustration of ...      Erik Malund      09/24/11 07:35      
                           You are right      Ralph Sac      09/24/11 18:39      
                              never too old      Erik Malund      09/25/11 06:46      
                                 Never too late to pick up a new trick      Per Westermark      09/25/11 09:10      
                                    One good trick ...      Richard Erlacher      09/25/11 13:49      
                                 Score -1      Michael Karas      09/25/11 19:59      
                                    Learn one before Jumping head      Ralph Sac      09/26/11 21:11      
                                       Learning Assembler First      Michael Karas      09/27/11 00:41      
                                          I wholehardely concur.      Erik Malund      09/27/11 08:03      
                        Thanks also you for your time      Ralph Sac      09/24/11 18:46      
   Here's something to try ...      Richard Erlacher      09/24/11 14:57      
   One suggession for higher frequency      Maunik Choksi      09/26/11 02:00      
      Remember no fractional part for      Per Westermark      09/26/11 06:02      
         Precise frequency      Mahmood Elnasser      09/26/11 09:00      
      I did not know that      Ralph Sac      09/26/11 21:15      
         89c2051      Stefan KAnev      09/26/11 22:10      
            When you wrote code      Ralph Sac      09/27/11 12:10      
               You normally always need to test - but may not need to debug      Per Westermark      09/27/11 15:20      
               it was example      Stefan KAnev      09/27/11 15:20      
                  Ok then if I      Ralph Sac      09/27/11 15:40      
                     try      Stefan KAnev      09/27/11 21:54      
                     depends      Erik Malund      09/28/11 06:54      
                     Testing Code      Michael Karas      09/28/11 07:25      
                        In short      Per Westermark      09/28/11 08:41      
                           someone said it better      Erik Malund      09/28/11 09:03      
                              "Proven Product" Syndrome      Andy Neil      09/29/11 01:24      
                     Did you ever look at that MIDE51 I previously mentioned?      Richard Erlacher      10/21/11 01:39      

Back to Subject List