I'm learning my way around a few new components, with the goal of ultimately building a small Z80-based computer. For breadboarding, I'm using a MEGA 2560 to provide the clock and to monitor pin state changes. This is all working perfectly.
Ultimately I'd like to replace the Arduino-based clock with a crystal oscillator like the MXO45HS 1M000000 (datasheet) which has been used in several retro Z80 projects (Example 1, Example 2), but I'm unable to get any signs of life out of the oscillator.
I'm using a digital interrupt on the 2560 to look for the output signal, and getting nothing. The interrupt does work if I use a pushbutton instead.
Things I've tried:
Added the recommended 10pF ceramic caps on both power input and signal output (see photo)
Also tried 22pF based on some old forum posts related to similar oscillators
Powered the part with an external 5V supply (though it should only take 80 mA at absolute max according to the datasheet)
Swapped to a different part (bought a few just in case one was DOA)
Switched INPUT_PULLUP to plain INPUT in case the internal pullup was affecting something
Grounded Pin 1 (though there should be no Enable required on this particular part)
I'm willing to admit I've got the wrong part, or that the Arduino can't see the the input (though it should be ~0.9*Vcc, or 4.5v), or that the Arduino can't keep up (kept the ISR as small as possible though).
Any suggestions? Short of getting a much more expensive oscilloscope I feel like I might be missing something fundamental.
Added the recommended 10pF ceramic caps on both power input and signal output (see photo)
Recommended by whom? How do you expect to read a 1.0MHz square wave using an interrupt pin? The ISR would be barely started before the next transition comes along.
A 1 MHz signal can easily be read by an Arduino: connect it to one of the timer input pins, set that timer to count the pulses, and a second timer to read that value at sensible intervals (you expect some 10,000 pulses in 10 ms, which fits comfortably within the typical 16-bit counter). Or set an overflow interrupt on the counter and check how long it takes to reach 65535 input pulses. This way you can count signals with frequency up to fclk/2 (i.e. 8 MHz on a 16 MHz Arduino).
Barely any processor overhead this way; this in contrast with interrupts indeed.
A scope is VERY useful indeed. I really like my DSO Quad from Seeed Studio. A pretty capable scope, can't do very high frequencies but perfectly adequate for Arduino level frequencies. 1 MHz is no problem for it. Not expensive at all.
As per the datasheet example circuit. Also various online tutorials (Example). If there's a better way I could use some guidance.
wvmarle:
A 1 MHz signal can easily be read by an Arduino: connect it to one of the timer input pins, set that timer to count the pulses, and a second timer to read that value at sensible intervals (you expect some 10,000 pulses in 10 ms,
Ah, excellent suggestion. I had forgotten all about hardware timers - will give that a try, thanks!
The code appears to work, as I get a frequency count of ~60 Hz when I leave the input floating (AC noise?), and 0 when grounded. So at least also I have the right pin.
I unfortunately get a count of 0 when connected to the MXO45HS output as well, so I'm no further ahead.
Might have to look at a scope to see the output after all.
The first thing I did before replying was read the data sheet. That is not an example circuit, it is not a recommendation. It is a test circuit. The capacitor on the output is to simulate external loads. You're not supposed to add one to your circuit just because it's used there.
"various online tutorials" are basically produced by "various online anonymous tinkerers", in my experience you can find serious flaws in more than half of them.
Ah, I see. I was trying to replicate their circuit as best I could...
Anyway, I believe I found it - the pinouts on the datasheet show the part from the bottom and not from the top (How is that useful?) So I had it backwards. It was much more apparent when I used the DIP-14 package instead of the DIP-8 (which is square).
Anyway, totally user error - working now. Thanks all for the input.