Intro, theory

I think I may have built an FM-transmitter with the least amount of general-purpose parts ever.

To see how I arrived at that conclusion, you'll have to know how the clock system of an ATTiny45 works. Just like almost every other AVR, this little 8-pin microcontroller has the possibility of generating an 8MHz clock signal using an built-in oscillator. This is quite handy when the AVR you're using has only a few pins; using the internal oscillator, you free the two pins you normally connect a crystal to.

The internal RC oscillator, however, has two major disadvantages. When used directly, the maximum clock limits the speed of the AVR: while most parts can run at 16 or 20 MHz, the fixed 8MHz clock means an AVR is only half as quick as its maximum speed, at most. The second problem is that the clock oscillator isn't precise: its speed can vary tens of percents between parts. Atmel solved these problems in the later parts, like the ATTiny45: First, they added a calibration register to tune the frequency of the RC-oscillator. They also pre-calibrated the RC-clock to 8MHz and stored the calibration value to reach that inside the AVR. The performance problem (and other problems, like slow PWM-speeds) they solved by adding a PLL to the AVR: this device takes the 8MHz from the RC-oscillator and multiplies it by eight, spitting out a 64MHz signal. This is then divided by 4, giving a nice 16MHz signal to run your AVR on.

With all that, the AVR (which has a maximum clock speed of 24MHz) can run on 16MHz from its internal clock. Sometimes, even the 16MHz is not enough, and some time ago, I found myself in a position where I could use that extra 4MHz. While browsing the datasheet, I found a way to do that: by writing the right value in the RC oscillator calibration register, you could make it run up to 50-100% quicker! So, I decided to take whatever was in the register, add 50% and use that as the new calibration value. All of a sudden, my AVR was running on a nice 24MHz.

Then I started thinking... if I overclock the AVR to 24MHz, the PLL runs at 4 times that frequency: 96MHz. Hmmm, that's smack dab in the middle of the FM radio band. FM means Frequency Modulation, which basically means the signal an FM-transmitter spits out is a carrier frequency, say 96MHz. That frequency is basically lowered and heightened a bit when the modulated audio signal is lower or higher. Hmm, using the calibration register, I should be able to do that...

 1 Next »

© 2006-2014 Sprite_tm - Contact