I have FINALLY found my ISP programmer and been able to check out the postage stamp controller and made it to the typical embedded "Hello World" application of a blinking LED.
The small board in the upper left is an ESP8622 wifi module that is hanging out from a previous project. I have flashed the ATMega328 part with the following typical example code:
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
The USBTinyISP programmer had no problem flashing the code to this part, but at initial blush, it appeared that nothing was working. Then after a very long delay, I saw the LED turn on. Reducing the delay values to 100 resulted in approximatly 1 second timing of the LED flashes. So, it appears that the clock was not running at 16 MHz.
On a whim, I decided to flash the optiboot boot loader to the device and let the device reset and then erase the chip and reflash the test application above with no boot loader present. This in fact fixed the problem.
In looking at the datasheet, I see the following:
So, it appears that out of the box, a new ATMega328 is going to default to a 1 MHz system clock. I will have to look at the optiboot code, but I am sure it is fiddling with the clock select bits which would explain the behavior I have seen.
In any event, I now have a tiny little microcontroller that needs no boot loader (saving that space in flash) and can be used for my projects that can use such a controller. I have a couple updates that I need do to the PCB and will publish my updates on OSHPark where anyone can order the boards as desired. $5 for 3 boards is a bargain. More to the point is that I got something useful out of an attempt to learn a little more about KiCAD.
Showing posts with label usbTinyISP. Show all posts
Showing posts with label usbTinyISP. Show all posts
Sunday, July 26, 2015
Sunday, April 10, 2011
Working with new tool chain
As the Arduino beacon project has progressed, I have spent some time trying to minimize the code size. For one thing, there are a number of components that the beacon project does not need that are drug into the final image. To do this I have moved away from the Arduino IDE for development of this project. I am using the GNU AVR tool chain now. I copied all the headers and code files from Arduino install and have been modifying them to eliminate components that I do not need. For example I don't need the serial port stuff, string classes, interrupt classes, etc. Rather than use generic port libraries, I am moving to talk directly to the ports instead. These kinds of changes have netted me 6-8 kb of space savings. I need to hack on the wire libraries to eliminate the stuff I am not using. Lastly, the Arduino boot loader is no longer necessary as I am using an in-circuit programmer (usbTinyISP) from the good folks at AdaFruit. This saves another 0.5 kb at the upper end of flash. The optiboot boot loader is pretty small, but others are not so compact. All things considered, the savings in code size are significant. Lastly, the tool chain is available for Windows, Linux and Mac platforms, so I think I will stick with it.
Converting from Arduino IDE is pretty straight forward:
1. Add #include "WProgram.h" to the top of your sketch.
2. Add a main() function at the bottom that calls setup() and loops calling loop() infinitely.
3. Provide forward declarations for all of your functions.
4. Create a Makefile to drive the build process if desired (recommended).
I copied all the components from my project into a new folder and built a Makefile to compile and link everything. Now I can hack on the Arduino components referenced in my Beacon project without affecting my Arduino IDE environment.
Converting from Arduino IDE is pretty straight forward:
1. Add #include "WProgram.h" to the top of your sketch.
2. Add a main() function at the bottom that calls setup() and loops calling loop() infinitely.
3. Provide forward declarations for all of your functions.
4. Create a Makefile to drive the build process if desired (recommended).
I copied all the components from my project into a new folder and built a Makefile to compile and link everything. Now I can hack on the Arduino components referenced in my Beacon project without affecting my Arduino IDE environment.
Subscribe to:
Posts (Atom)