I am in development of a system useing the ATMEGA168 chip. I am down to selecting a crystal, I want 16Mhz. After doing some reading of many post/articals I am confused about one thing.
Some state that if I use RS232 communications, I should use a Crystal, others say it doesn’t matter - which is it? I will be useing the TX/RX pin at 9600. Also, the Arduino Pro mini uses a resonator and seems to communicate just fine - So I am leading to believe that it doesn’t really matter until I get into very complex / timming sensitive programing.
If I use a crystal, does anyone have a link that shows how to select the parellel Caps for the Crystal to get 16Mhz? I could cheat and just copy what is already on the proto, but I want to know how to they got those values.
I suppose you mean a ceramic resonator, a crystal is a resonator as well. The former should give sufficient stability and accuracy for async comms, I’ve often used them for that purpose with AVRs.
The feedback capacitors used with a crystal (or two terminal resonator) depend on the specified load capacitance . They can be considered as effectively in series, so 33 pF is probably suitable for a 20 pF crystal, allowing for some stray capacitance. This is just a ballpark figure, if a unit is going into production the oscillator needs to be tested thoroughly over a range of temperatures and the effect of component tolerances ascertained.
Usually the datasheet for the crystal will tell you what load capacitance the crystal is designed for. I’m currently building a project with an 8MHz crystal and the load capacitance is specified as 18pF for the crystal I’ve selected. Different crystals have different requirements, so the datasheet (if you know what part you’re using) would be important to have.
At 9600 baud, clock drift isn’t as critical as it is when you’re trying to use something like 115,200 baud. My rule of thumb is that the lower you can get the baud rate, the more reliable it will be at the expense of communication speed. I’ve also successfully bit-banged 9600 baud without using a crystal. In that particular case, I used the internal RC oscillator on the microcontroller. It probably wouldn’t be very stable over a range of temperature variations, but it suited my purposes at the time.