Go Down

Topic: fastest speed of input pins, hardware prescaler (Read 567 times) previous topic - next topic

edzy

I would like to connect a very precise crystal, around 11MHz, to an input pin of the Arduino (running ar 16MHz), then use a hardware prescaler in the arduino, if that exists, and ultimately trigger my code at a fraction of that 11MHz, maybe divide by 256. I don't know if I can do the divide by 256 inside an interrupt, since the few instructions it will take will overlap the next 11 MHz beat. So is there a way to set timers or prescaler so that the interrupt is called every 256 beat on the pin ?
Thanks !

shelleycat

Why not run the arduino at 11MHz?  It will run if you change the crystal or build a standalone board.
Then you can run a timer (e.g. timer2) using a prescaler on the clock frequency.  Your millis() timer would be out, but perhaps
that doesn't matter to you.  I don't think there is any internal prescaler you can use.

Or you could use a standalone board with an 11Mhz crystal, driving its own timer,  feeding into a second arduino.
That takes a 328P chip, two capacitors, a crystal and a resistor + capacitor for the reset line.  You could even write
the sketch to work on the arduino, then move the chip to your standalone board.

JoeN

Connect an 11mhz oscillator to a counter and have bit 8 tied to PD2 or PD3 and set it for a pin rise interrupt?
I have only come here seeking knowledge. Things they would not teach me of in college.

oric_dan

Not exactly mentioned, but you cannot simply connect a crystal to an Arduino
pin and have it oscillate. You need an "oscillator" circuit for that, like on the
Arduino crystal pins.

I haven't done this specifically on Arduino, but built-in timers are in fact designed to
do the sort of counting you want.  You can set up their prescaler value and rollover
period [value=1..256], and trigger an interrupt with the rollover, so you can basically
get any rollover value you want.

Go Up