??? 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 |