Arduinos & Breaduinos
Programming raw AVR's
Using SPI interface for AVR programming
- board ID: breaduino1
- name, which is what appears on the menu boards
- fuses: low = 0x62, 0xd9 = high and extended = 0x07
- f_cpu: 1000000L corresponding to the speed of 1MHz
Just check micro-controller and programmer documentation for the pin-outs of:
MISO - Master Input <- Slave Output
MOSI - Master Output -> Input Slave
SCK - Serial clock signal pulse synchronization of data transfer
SS - Slave select, do not use. Unfortunately, the specification does not include the use of this pin, it would allow us select the target to program.
Simply connect the respective pins of the micro-controller and programmer to establish the communication bus.
In addition to communication, the SPI programmer includes a reset pin that must be connected to uC reset pin. If this pin does not exist in the programmer you may plug the resistor to ground during the SPI programming process.
These programmers can also p'ower the micro-controller if the assembly does not include its own power supply, if the assembly has its own power supply, connect the ground only.
We use the Arduino IDE to load programs using this interface (SPI programmer)
Just open the blink sample sketch for a test
On the tools menu:
Board: Arduino Uno
Port: Select any (IDE requires a selected port, although avrduide ignores it for this USBasp programmer)
Programmer: USBasp
The first upload can be made by using the option:
File-> Load using a programmer
The sketch will be compiled and loaded, however the program will run 16 times slower because this circuits come with factory settings to work at 1MHz.
We can fix this by keeping the uC running at 1MHz but nevertheless telling the Arduino IDE the chip specifications, because the board settings for the chosen "Arduino Uno" board are for 16MHz.
This is done in a boards.txt file if (create if not existing) in the following location:
(Folder Sketches) / hardware / arduino / boards.txt
just add the following definitions:
############################################
breaduino1.name=Breaduino 1Mhz (RA 2014)
breaduino1.upload.maximum_size=32256
breaduino1.upload.speed=115200
breaduino1.bootloader.low_fuses=0x62
breaduino1.bootloader.high_fuses=0xd9
breaduino1.bootloader.extended_fuses=0x07
breaduino1.bootloader.path=optiboot
breaduino1.bootloader.file=optiboot_atmega328.hex
breaduino1.bootloader.unlock_bits=0x3F
breaduino1.bootloader.lock_bits=0x0F
breaduino1.build.mcu=atmega328p
breaduino1.build.f_cpu=1000000L
breaduino1.build.core=arduino
breaduino1.build.variant=standard
These definitions were copied from the definitions of the arduino uno board, we only modified a few parameters:
this way the Arduino IDE will know how to treat this chip and will generate the correct code for the delays corresponding to 1MHz speed.
The listed fuses are for an ATMega328P running at 1MHz (factory settings)
The fuses are internal uC settings controlling its operation in several aspects.
They are of utmost importance and changing them incorrectly can damage or disable PERMANENTLY the uC, so we recommend caution.
We use the same tool that is used in arduino IDE to load programs into the uC and that also allows iteration with the uC. In this case we will just confirm the values ??of fuses and also use an online fuse calculator for a confirmation.
Using avrdude in a command line:
avrdude list of command line parameters
avrdude -p? List supported uC codes.
avrdude -pm328p -cusbasp checks the connection between the usbasp programmer and the ATmega328P micro-controller
avrdude -pm328p -cusbasp -t opens avrdude in terminal mode so we can issue other commands.
type ? inside the terminal for a list of valid commands
reading fuses values:
read lfuse get the value of low_fuse
read hfuse get the value of high_fuse
this uC has an extended fuse
read efuse get the value of extended_fuse
value of 0x07 in efuse listing differs from that shown on the website because only the first 3 bits are used on the uC,
The fuses have an inverted logic where 1 equals to not programmed and 0 to active.