I am in dire need of help from you. I come from a computer programmign background, and have basic idea of what baud rate is and what role clocks serve in synchronous circuits. However, I had np idea that something as simple could give me so much pain. The more documents I read on this subject the more frustrated I become, therefore I have resroted to asking in forums instead of reading books. I really need someone who I can ask stupid questions to. Will you help?
The way I understand it:
- Bitrate = Oscilator frequency / Clock divisor;
- Baud rate = Bitrate / Size of one baud;
- Size of a baud= Start bits+ Data bits+ Parity bits+ End bits
Therefore, to calculate baud rate, we need the following info: oscilator frequency, clock divisor value, baud size.
Nowhere in the documentation of AT89S52 (the first Microcontroller that i tried to program) do they mention the internal oscilator frequency. However, it does mention that it can accept an external oscilator, which is very good and dandy until I realized that it does not mention the divisor value anywhere.
I have tried to program many other microcontrollers since; including ATMega 8, ATMega 328p etc, and none of the documentations seem to mention any of the required data for calculating baud rate. Instead, they keep talking about internal baud rate generator, mention a lot of formulas, UBRRn, Fmod, SMOD, TCLK, T2CON, RCAP2L etc etc. Previously I had the idea that baud rate will be among the first things mentioned in the documentation alongside voltage tolerances, footprint, pin mapping etc. Where in the documentations do I look for the data required to calculate baud rate?
The crystals I use are two legged. The tutorial videos like this one (https://www.youtube.com/watch?v=...) also seem to use the two legged ones. But ric from Microchip forum mentions that the two legged ones are just crystals, not the whole oscilators. That thread mentions there are three types of crystals:
- Two legged barebone crystals,
- Three legged crystals with capacitors,
- Four legged complete oscilators that require power and ground.
The last ones are the only ones that release logic level square waves.
So what's really up with the value KDS11.0592 that is writen on the two-legged crystals I have? Do the microcontrollers have internal oscilators and only need a crystal between XTAL1 and XTAL2 ? If I connect a crystal between XTAL1 and XTAL2 on a chip, how can I determine the actual oscilator frequency from the crystal value?
The answer to this question might also answer the following questions:
- Kerry D Wong,s baud rate calculator spreadsheet requires "crystal baud rate". How can crystals have baudrate? I thought all they do is to release a square wave.
- Wormfood's baud rate calculator requires bitrate as well as crystal frequency. So those two are different somehow? How?
When trying to program an IC using Arcuino ISP and AVRDUDE, I keep getting unknown signatures of the format 0xffff00 / 0xff8000 instead of 1E 52 06 / 1E 95 0F. If I try to force write, all I get is : Writing | ***failed;
and so on. I have been hard ressed to find any information on this error in Google search. It seems this error is pretty rare. What am I doing wrong here? Any idea?
BTW, it is not the fault of the IC because I have tried multiple copiess of AT89S52 as well as ATMega8A and ATMega328P. I am assuming that this is baud rate issue because I have no idea about that one parameter. Or is this something else altogether?
About why I am using an Arduino as ISP instead of an USBASP, the answer is: fischl's USBASPs are not available here. I bought a local one but that is not even being detected as a COM port. However, it is another matter altogether.
Thanks in advance.