Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!execu!sequoia!uudell!bigtex!texsun!geraldo.Central.Sun.COM!cronkite!exodus!oobleck.Eng.Sun.COM!bender From: bender@oobleck.Eng.Sun.COM (memory fault - core dumped) Newsgroups: sci.electronics Subject: XTAL not oscillating at marked frequency Keywords: wierd crystal stuff Message-ID: <15604@exodus.Eng.Sun.COM> Date: 21 Jun 91 08:00:17 GMT Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 55 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