Unfortunately, if you look at the screenshot where I've got the external clock on Channel 0 (top signal), the Arduino lagging behind and outputting a lot slower (around 190kHz).
I'm not an expert on the Arduino hardware so if anyone can help explain why this is, I would appreciate it.
It's an old board from an E&M rack (ham radio/comms). I don't have it hooked up yet though. It's just the Arduino and an external clock source at the moment,
I'm not sure what you mean about it looking right though.
My expectation was that at each rise on the clock signal, the output should flip. At least that's what I think the code should do.
I don't understand why the Arduino is lagging by 14 cycles?
I don't understand why the Arduino is lagging by 14 cycles?
Because of the time it takes to deal with the interrupt. You are feeding a signal which is not too far from the processor's clock signal, and there is not enough time to catch every cycle of your signal.
Interrupt servicing involves preserving the state of the machine before the ISR code is run and then restoring it after it is finished.
holmes4:
First there is no "lag" the processor is just losing all the interrupts it can't deal with.
Well that is why I said it's lagging, because it's not fast enough to deal with all the clock rises especially when the interrupt stops every other process. Grumpy_Mike's explanation was very clear.
holmes4:
Second just WTF are you trying to do!
When people ask me for help I try to be as polite as possible and would appreciate the same.
Slumpert:
If you know the frequency then why are you still monitoring it and trying mimic it at same time?
Slumpert, the reason for the code above was to gauge the ability of my Mini Pro to be able to do what I want it to do with the program I am planning on putting together.
The device is an analogue to PCM converter I bought at an auction and interfaces nicely with some radio gear I have laying around.
The way it receives and transmits data is simple, via a 20-bit transaction at clock speed:
A 10 bit string must first be sent to it which contains the data (start bit, data, etc).
It will then respond with 10 bits of its own.
That's it. I think it's somewhat similar to the SPI function but could be wrong.
Anyway, this is a long-term project I want to work on, it's been a goal of mine for a while. I look at the pile of wires and the breadboard in my cupboard sometimes and every now and then I take it all out, hook it up to my computer and play around with it.
All I am trying to do now is figure out if my Arduino hardware will be sufficient, or if I need to look at a Teensy or even an FPGA (which I have no experience with).
From what Grumpy_Mike has explained, it might be best to look at another platform.