Pages: [1]   Go Down
Author Topic: fastest speed of input pins, hardware prescaler  (Read 543 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 !
Logged

UK, Southwest
Offline Offline
Full Member
***
Karma: 5
Posts: 138
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Danger Boy
Offline Offline
Edison Member
*
Karma: 14
Posts: 1108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Connect an 11mhz oscillator to a counter and have bit 8 tied to PD2 or PD3 and set it for a pin rise interrupt?
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: