Sunday, July 26, 2015

Controller check-out

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.

No comments:

Post a Comment