Monday, August 19, 2013

3208Clock Part 3: Implement the board into the Arduino IDE

General overview

In this post we take a closer look into the configuration of the Arduino IDE and we also upload the first test sketch to the 3208Clock.


24. Jul.2016:
I figured out that the following descriptions does not work anymore for the actual Arduino IDEs (> 1.5.x). I have no clue how its done now and i assume its a similar way to implement the new board but at the moment i dont have the time to do it.

Add the new board to the configuration files of the Arduino IDE

There is a configuration file called boards.txt in the program folder of the Arduino IDE. It can be found here .../arduino-1.0.5/hardware/arduino/boards.txt. Open this file in a text editor and add the following lines at the end of the file and save the file. Then start/restart the Arduino IDE. Now there is an entry called "Lattice Clock w/ ATmega8" in the Arduino IDE which can be found in the menu Tools - Boards. Clock w/ ATmega8

The entries in the boards.txt are more or less self explaining but we still want to venture a further look on the parameters. Clock w/ ATmega8

With this parameter the name which will be shown in the Arduino IDE under the boards section can be set. In this case its "Lattice Clock w/ ATmega8"


This parameter sets the maximum upload size of the hex-file. in this case we can use the complete 8192 bytes (8kB) of the ATmega8L program space. It is not necessary to install a boot loader on the device because the ICSP connection will be used.


With this two parameters the two bytes of the fuses will be set. The fuses are the internal configuration of the Atmel chips.
With this fuse settings the reservation for the boot loader in the flash space is disabled and it is also set to a clock frequency of 8MHz from the internal oscillator.

IMPORTANT! If you don't know exactly what you are doing with the fuse settings then it is very easy to reduce the usage of the device to a paperweight. Changes are at your own risk.

This parameter tells the compiler of the Arduino IDE which micro controller is used.

This parameter sets the information of the clock speed (in this case 8000000Hz or 8MHz). This parameter is used by the compiler to calculate some constants which will be used by some of the internal hardware of the ATmega e.g. usart / serial connection.

I'm not sure what this two parameters are doing. If someone has an idea please leave me a message in the comments.

Burn the fuses

Select the board "Lattice Clock w/ ATmega8" in the boards menu and select the programmer (If you use an Arduino as a programmer then select ArduinoISP). Both can be found in the Tools menu.

IMPORTANT! If the wrong board is selected for example the Arduino NG or older w/ ATmega8 then you will brick the 3208Clock because the fuses for this board configure the clock source to external 16MHz quartz. The 3208Clock does not have an external 16MHz quartz.

After the correct programmer and board has been selected go again to the tool menu and click on Burn Bootloader. In our case it only flashes the fuses and erases the chip.

Build a "Test LED" and flash the test sketch to the device

I guess a picture says more than thousand words. I have used a 1kOhm resistor. Everything between 330 and 1000 Ohm will be fine. Also the selection of the LED is not critical any common LED which emits visible light will fit. It is also not necessary to solder the LED to the board for the first test it only needs to be plugged through the holes of the DS18x20 footprint.

If the LED is prepared so far then please download the test sketch from my github repository or use the blink sketch from the examples and change the ledPin from 13 to 15.

To burn the test sketch to the 3208Clock you must hold the shift key while clicking the upload button. Otherwise the Arduino IDE tries to use the serial connection to upload the sketch which will cause an error message.

In the next posts we will take a closer look on how to get in contact with the Holtec HT1632C display driver to get something shown on the display.