bender@oobleck.Eng.Sun.COM (memory fault - core dumped) (06/21/91)
I had an interesting experience these past two days. Last night I was writing some 8051 code for a project that I'm working on and loading the code into my 8051 emulator; the code was nothing complex, just a timer setup to interrupt at what I thought was 2mS intervals, but instead of getting interrupts every 2mS, I seemed to be getting them around every 6mS or so. So, I checked my code, made sure that I understood the correct value to stuff into the timer registers, made sure that I wasn't doing something silly like flipping a port pin every OTHER interrupt, and all of the other usual software stuff, but still, I wasn't getting interrupts at the frequency that I thought I should be getting them. I then decided to get down to basics, and just drive a pin high, execute 4 1-cycle instructions, then drive it low, and jump to the top of the loop. I reasoned that at my processor's clock speed of 12 MhZ, the port pin should be high for around 5uS, and low for around 3uS or so, but I was still getting much longer high and low times. Back out with the 8051 data book, check the instruction cycle times, even check my scope (!), but I could find nothing wrong, it just seemed that the processor was executing much more slowly than it should have at a 12 MhZ clock! So, I called the emulator company (American Automation) and talked to a designer (Joe), and he ran the same code loop on his system and his times were what I thought mine should have been. He then suggested checking the emulator's clock, since I was using the emulator's internal clock rather than providing my own XTAL/cap combination, and sure enough, the emulator's clock was running slow; as a matter of fact, the 24 MhZ XTAL that was in the emulator was oscillating at about 8 MhZ! I replaced the 24 MhZ XTAL with a 12 MhZ XTAL, and the oscillator fired right up at 12 MhZ, so I'm pretty confident that the oscillator itself is OK. Joe said that sometimes crystals go bad and won't oscillate at their marked harmonic frequency, but rather oscillate at their fundemental frequency, and this sure seemed to be what was happening. I haven't replaced the 24 MhZ XTAL yet, but I did provide my own 12 MhZ XTAL/caps and got the processor working at the correct speed. What exactly is the failure mode here? Do crystals go "bad"? Here's what the oscillator circuit looks like: +-------------------||-------------------+ | 0.1uF | +--/\/\/\--+ +--/\/\/\--+ | 330 | | 330 | | |\ | | |\ | +---| o----+---+---|[]|-------+----| o---+ |/ | 24 MhZ |/ LS04 | LS04 | |\ +----| o--------> 24 MhZ out to divider |/ LS04 any ideas? mike -- ------------------------------------------------------------------------ 1985 Honda Shadow VT1100 | DOD #000007 1989 Honda NX-650 | AMA #511250
rcarter@wpi.WPI.EDU (Randolph Carter (nee. Joseph H. Allen)) (06/22/91)
The ghost of bender@oobleck.Eng.Sun.COM (memory fault - core dumped) writes: >clock was running slow; as a matter of fact, the 24 MhZ XTAL that was in the >emulator was oscillating at about 8 MhZ! I replaced the 24 MhZ XTAL with a This is exactly what a common 3rd overtone crystal will do when it's not loaded properly. Try changing the values of the resistors in the crystal circuit or a different circuit. This is my favorite: +--------|O|--------+ | | +---R---+ | | | | +--|>o--+---|>o-----+--|>o---o out Try about 220 ohms for R and use a 7404 for the inverter instead of a 74LS04 -- /* rcarter@wpi.wpi.edu */ /* Amazing */ /* Joseph H. Allen */ int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0) +r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2 ]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}
lrk@k5qwb.lonestar.org (Mr. Lyn R. Kennedy) (06/22/91)
bender@oobleck.Eng.Sun.COM (memory fault - core dumped) writes: > > What exactly is the failure mode here? Do crystals go "bad"? Here's what > the oscillator circuit looks like: > > +-------------------||-------------------+ > | 0.1uF | > +--/\/\/\--+ +--/\/\/\--+ > | 330 | | 330 | > | |\ | | |\ | > +---| o----+---+---|[]|-------+----| o---+ > |/ | 24 MhZ |/ > LS04 | LS04 > | |\ > +----| o--------> 24 MhZ out to divider > |/ > LS04 Welcome to reality. There is nothing in this circuit to make the xtal operate at 24 Mhz. If it's an 8 Mhz fundamental, you should expect it to work there. You might try a series-tuned circuit in place of the 0.1uF but I doubt you'll find any simple way that works well. Best bet is to get a good circuit out of a handbook and put it's output into one of the LS04 inputs. ------------------------------------------------------------------------- 73, lrk@k5qwb.lonestar.org Lyn Kennedy K5QWB @ N5LDD.#NTX.TX.US.NA P.O. Box 5133, Ovilla, TX, USA 75154 -------------- "We have met the enemy and he is us." Pogo --------------
mcovingt@athena.cs.uga.edu (Michael A. Covington) (06/22/91)
Any crystal rated between 20 and 60 MHz is going to be a "third overtone" type which is capable of oscillating at both F and 3F, where 3F is the frequency marked on it. For example, a 27-MHz CB crystal will also oscillate (in fact will more easily oscillate) at 9 MHz. Very simply, your 24-MHz crystal chose to oscillate at its 8-MHz fundamental rather than its 24-MHz overtone. (You could also get it to oscillate at 5F, which is 40 MHz, in a suitable circuit.) Overtone crystal oscillators almost always contain a tuned circuit to prevent oscillation at the lower frequency. Your circuit doesn't look like an overtone oscillator; it has nothing to prevent oscillation at the lower frequency. You might *try* replacing the .01 uF capacitor with something a lot smaller, but don't count on it. The easiest thing to do, if you're clocking a microprocessor, is to use a hybrid IC oscillator -- that is, a whole oscillator in a can the size of an IC. These have all the frequency-determining components built in; just apply 5 volts and you get a nice 5-volt square wave out. -- ------------------------------------------------------- Michael A. Covington | Artificial Intelligence Programs The University of Georgia | Athens, GA 30602 U.S.A. -------------------------------------------------------
PS02@NS.CC.LEHIGH.EDU (Penelope E. Smith) (06/22/91)
On Crystal Failure: 1) It is possible to overdrive a crystal and crack it. 2) It is also possible to drive a crystal at an unintended harmonic, depending on your circuit. 3) See Horowitz & Hill (The Art of Electronics) for a good crystal oscillator. Good Luck ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Penelope E. Smith PS02@NS.CC.LEHIGH.EDU Department of Mathematics PS02@LEHIGH.BITNET Lehigh University Bethlehem, PA