by bobs bots » Sat Feb 16, 2013 12:26 am
Hi Guy sherman,
I'm from the West Island.
PS you have the exchange rate backwards $6NZD=$5.1USD.
(a)
The frequency is also important. If you want to use the Arduino bootloader , you are stuck with 16MHz , that's not such a a bad thing, I generally use 16MHz anyway.
If you want to use fast baud rates (above 38400) , you may be better off to use a baud rate crystal, I think 14.132 is popular, but it may be difficult with baud rate crystals to generate "round numbers" from the timer/counters , so you can make 10kHz with a 16.00Mhz clock , and you can make 9.000kHz with the 14.132. I used to use 14.132 , but they are harder to find , and it turns out at 19800bd, the error is only 0.5% with 16MHz.
SPI and I2C don't care about exact frequencies.
(aa) the CPU current draw goes with frequency eg 16mA at 16MHz , something to think about when using batteries.
(aaa) if you want to run interrupts (e.g. so you can have buffered serial , and background timer operation) you generally can't run with a lower frequency clock. For example 8MHz and 38400Baud is very difficult , 16MHz and 19200 is good. At 38400bd, you need to ensure that the ISR for the serial is able to be called at ~4kHz (i.e. each 250uS)
You will have problems for example trying to read all 12channels of an I2C ADC in each time slot, so you need to break it up into two. You may even have trouble reading the internal ADC.
(aaaa) I generally use 16MHz , and run a background ISR that is called at 2.000kHz , this counts up to twenty "phases" or slots, so each of twenty "tasks" runs at 100ms intervals, and one second is then 100 ticks. I can run two serial ports, some I2C parts, the internal ADC , and everything meshes together nicely.
(aaaaa) The fastest baud rate I have used on an AVR is 5Mbaud with a 20MHz crystal , this requires the "turbo" UART mode (This was for an encoder interface, I discarded 99.9% of the packets)
(b) Resonators are usually a better option than crystals, they are way cheaper, Mouser have the AWSCR-16.00MTD for 18c at 1000 off . They occupy less PCB space , and they don't need the fiddly little caps, the accuracy is worse than crystals , like you might lose a minute a day instead of a few seconds , (but an ordinary crystal is not good enough for a stand alone RTC , so why bother)
(c) The Avr's have some fuses that can be blown, you should use the "large swing" option for the crystal , the other option makes them a bit sensitive to touching of the crystal.
(d) Cascading of the Xtal , In theory this is possible, but in practice generally not, unless you use a CPU with a separate clock out pin. I've tried to run a encoder interface using the "output" leg of the crystal, but the capacitance of the PCB trace, and the chip input capacitance eat up the 22pF crystal padding. It was very unreliable.