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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/17/11 22:09
Read: times


 
#183791 - Legible source code
Responding to: ???'s previous message

Hi to all members:

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. 

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