NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Everything Else » Overclocking your nerdkit
May 15, 2009 by Fahr |
Hello everyone, I just figured this out the other day and thought I'd share in case anyone else was interested. I wanted to run AVGA (a wonderful library, found at http://avga.prometheus4.com/) on my Nerdkit. The default example uses an overclocked Atmega168 that runs at 25mhz. Since it generates a video signal, it's critical that the software is compiled for the right clock speed. It's possible to compile for 14.7456mhz, but that leaves a very low horizontal resolution. So I opted to go for the 25mhz instead. Here's what I figured out about overclocking the nerdkit; First of all, I've had this discussion by email with Mike. He pointed out that it's perfectly fine to swap the crystal for a faster one to run software already on the chip, but it wouldn't be possible to load new software onto the chip. This is because the bootloader that the Nerdkit ships with is fixed at the 14.7456mhz which is used for the serial clock as well. (14745600 / 8) / 16 = 115200 - the serial BAUD rate used to connect to the UART port. (if you want to know why 8 and 16; check the Atmega168 manuel for UBRR). Note that AVGA works fine at 25mhz if you upload the software with the 14.7456mhz crystal plugged in and then swap it to run the software. This wasn't something I wanted to do all the time though. I also don't have a real AVR programmer to change the bootloader with. So I tried something else. Using a 25mhz crystal and the same values (8 and 16) to calculate the BAUD rate, we get (25000000 / 8) / 16 = 195312.5, or 195313, rounded up. A bizarre value for a BAUD rate, but I thought I'd try it anyway. Connecting with Putty to the COM port with 195313 set as the BAUD rate showed me that the nerdkit responded just fine (in programming mode, the bootloader send "bp" across the UART port). So it seems that arbitrary BAUD rates work! The next problem was avrdude, the tool used to upload software onto the chip. By default, avrdude only supports known BAUD rates. 195313 isn't a known BAUD rate, so it produced an error and died. I downloaded the source for avrdude 5.6 and tinkered with it so that it would accept arbitrary BAUD rates. After compiling and testing it turns out it works fine. I'm now running my Nerdkit at 25mhz and uploading software into it with 195313 BAUD. I posted my findings to the avrdude dev list and they asked me to submit a patch. The patch for avrdude 5.6 can be found here; https://savannah.nongnu.org/patch/?6828. It will most likely be incorporated in the not too distant future. Avrdude can be compiled on Windows with MSYS and MinGW. If you need any help (or want a binary), let me know. Joerg Wunsch, one of the people behind avrdude, did point out that arbitrary BAUD rates may not work with every piece of serial hardware, which is why there's still a warning when using them. I do know it works with the USB Serial adapter that comes with the Nerdkit. Happy hacking! |
---|---|
May 15, 2009 by TBNK |
This is excellent information, well presented. Thanks for this report. And thanks for the link to the AVGA library, too. |
June 14, 2009 by BobaMosfet |
I guess the only question I have is whether or not the MCU can actually handle overclocking? I'm sure to an extent, but depending on how much heat that generates, it will shorten the life of the chip. Does your chip get warm or hot at all? |
July 24, 2009 by Fahr |
Sorry for the late reply... I haven't checked in a while. My chip is still running fine on 25mhz, no extra heat as far as I can notice. Then again, 25 isn't a long shot from 20 - the official max. |
November 17, 2009 by pbfy0 |
the patch shold be here (http://savannah.nongnu.org/patch/?6828) |
November 17, 2009 by Farmerjoecoledge |
Hey! Far-out! Right down my crystal "trail". Farmer |
November 18, 2009 by Farmerjoecoledge |
Hi Fahr, I'm looking over your info, good stuff by the way, and got a couple q's. What's your device that accepts NTSC in RGB-SYNC form? "cat" question. Next question after this one. farmer |
July 21, 2010 by rommjp |
Hello Fahr! I've lost my original crystal that came with my NK a few days ago so I figured buying a few new clocks from the local electronics store and reprogramming my chip, however I found that this exercise was not so easy! I stumbled on your article about setting new BUAD rates to allow for programming the chip without using the original 14.7456mhz crystal. I think what you did was a gold mine!.. as I have been trying to find information about communication to the atmega chip without using the 14.7456mhz crystal (as these are hard to come by!)... Would you mind sending me instructions how to recompile Avrdude to accept arbitary baud rates as you did, as reading your earlier post I think it over simplified the process.. (unfortunately, I'm not familiar with MSYS and MinGW) My email is rommjp@yahoo.com.au or you can setup the instructions here so its public. Thanks alot for this! |
Please log in to post a reply.
Did you know that multiple microcontrollers can communicate with each other? Learn more...
|