NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Speed up the Nerdkit
September 02, 2010 by Rick_S |
I have to admit, I like the serial bootloader over ISP... even though I have both. However, I wanted to run my micro closer to it's rated 20MHz rather than the 14.7456MHz the Nerdkit is clocked at. I realized that the reason this value was chosen was to maintain an error free standard baud rate over the serial port for programs requiring communications to the PC. Then I came across the section in the data sheet that shows the margain of error for serial communications with various crystal speeds and noticed that an 18.432Mhz crystal also offered an error free communication. I thought I'd pass the process along in case anyone else is interested. WARNING: IF YOU HAVE NEVER FLASHED A BOOTLOADER OR USED AN ISP PROGRAMMER BEWARE --- I AM NOT RESPONSIBLE IF YOU MAKE YOUR BOOTLOADER UNRESPONSIVE. WHILE THIS WORKES GREAT FOR ME YMMV!
In step 2, the files in the bootloader folder that need modified are: config.mk uart.h In config.mk, you need to make sure the settings for the ISP_DEV and ISP_PROG match that of your ISP programming device. You also need to change the frequency for F_CPU. In my case, these lines looked like this for my 328p micro.
In uart.h, you have to add an elif for the new frequency. This is the section from my uart.h
Once this is done, you will need to re-compile the foodloader.hex and flash it to the chip. At this point, the serial bootloader should work exactly as before only now with the 18.432MHz crystal (Note: the old crystal will no longer work with the bootloader at this point so do not do this without the new crystal in hand) The only other change is to make sure UBRROL is set to 9 instead of 7 in the uart.c file in the libnerdkits folder.
Now I made this post just before going to work... so I'm a bit rushed :D so please do not attempt in case you are 100% sure what you are doing. Rick |
---|---|
September 03, 2010 by Rick_S |
Quick question for the guru's. Were the changes I made all that needed to be done to implement the new freqency crystal I used? It all seems to be working fine, I just want to make sure my instructions are OK in case anyone else wants to increase the speed by 25%. Thanks, Rick |
September 03, 2010 by Ralphxyz |
Rick, you know you are becoming a guru. And I sure appreciate it. Ralph |
September 03, 2010 by Rick_S |
Thanks Ralph for the compliment, however, there are many here more guru-ish than I. :D |
May 18, 2011 by kle8309 |
If I just wanted to recompile the foodloader to get the foodloader.hex, do I need to make any change to the setting. Because when I try to make all I'm keep getting error
about the device connection. But all I want is to compile and not upload. It is
almost if I have to make the right hardware setting before it will compile. Is there away around this. I have the stk500 usp programmer. |
May 18, 2011 by Rick_S |
Did you make changes to the bootloader that you are wanting to compile? If so, you can just modify the make file so it doesn't do anything but compile, or just type the steps individually to build it. If you didn't change the bootloader, there is already a compiled hex in the folder. Rick |
May 18, 2011 by Ralphxyz |
There is a nice breakdown of the Makefile in the Nerdkit's Library. Rick, I know your Makefile for the I2C Real Time clock uses "make" to just compile the code, which lines in your Makefile does that? Also "make program" compiles and loads the mcu, which lines do that? Ralph |
May 18, 2011 by kle8309 |
Rick, can you please post your Makefile so I guess we have to write our own makefile to compile to get foodloader.hex because this is all that is in the makefile:
Which basically just change the fuses and upload the hex file and not recompile it. |
May 18, 2011 by kle8309 |
Oh, I found the makefile to compile it it's the makefile.fl all I have to do is change the name to makefile so programmer notepad can make. I also have to take out the other upload makefile. It made the .hex I wanted but also showed an error:
|
May 18, 2011 by kle8309 |
Which header file contain the definition for cfsetispeed I can't find it |
May 18, 2011 by Rick_S |
That s the nerdkit makefile for installing the pre-compiled hex file they include. There is also a file called makefile.fl in that folder. Just rename Makefile to something else then rename Makefile.fl to Makefile. That makefile will compile the bootloader for you. Rick |
May 18, 2011 by Rick_S |
If I compile, I don't get an error using the default files. Did you change something? |
May 19, 2011 by kle8309 |
I think I have changed the avr.mk and config.mk.
Let me try to compile w/o changing anything. Rick, Did you comment out the SERIAL_DEV in the config.mk? Also you mention about the changing the only config.mk above and the uart. So what about the avr.mk settings? Will config.mk override the avr.mk |
May 19, 2011 by Rick_S |
This isn't used for compiling, only for sending to the chip and then only if you are using a serial based programmer. But no, I didn't change any of that. Rick |
May 19, 2011 by kle8309 |
OK, I got it to work. I must have changed something when I messed around. I have downloaded the original NK code and compiled that. I wished there was a README file explaining the renaming steps There are two ways to compile this: Using terminal cmd
Using programmer's notepad (I used) change the makefile.fl to makefile (must also rename the other makefile to makefile.somethingelse). Then click make all. the original makefile is just fuse/lock settings and uploading the foodloader.hex I think it would be easier to understand if I change the uploading makefile From
To
|
May 19, 2011 by Rick_S |
Glad to see you got it. Was the reason you needed to compile the source because you plan to make changes? Rick |
May 19, 2011 by kle8309 |
Yes Rick, I just bought 2 new 40 pin MCUs: Atmega644 and Atmega32 I want to have them work with the foodloader But behind all of this, I want to drive the graphic lcd from allelectronics.com I found a group of people working on the glcd but with Atmega644. |
May 20, 2011 by Rick_S |
That reminds me, I bought a 40pin atmega324p a while back and was going to do the same thing... Just never got around to it. Rick |
May 20, 2011 by Ralphxyz |
Kevin, keep us posted on whatever you do with the ATmega32. One came with my Dragon programmer so I have one to play around with also. I also just picked up some ATmega64M1 mcus to see if I can do something with the OBD-II CAN bus. It would be good to document loading the bootloader onto different mcus. Ralph |
Please log in to post a reply.
Did you know that the microcontroller's crystal oscillator can be used to keep accurate time? Learn more...
|