sábado, 7 de fevereiro de 2015

Arduino nano programming ATtiny13A

In this first post i want to make me remember how i managed to make my first Arduino nano to program a little ATTiny13A bought from Aliexpress. Here i will post some inittial errors and attempts.

As any good googler, my first thought was "certainly there is someone in this world who already done it." and indeed there's many people who done. But unfortunately none of them worked for me mainly because of schematics and i dont know why it did worked for them.
So, done with dumb thoughts, let's get to work ;-).

Following instructions from several sources, i programmed the arduino nano with the example ArduinoISP, and after reading the comments on the header of that source code, I found the solution:


// This sketch turns the Arduino into a AVRISP
// using the following arduino pins:
//
// pin name:    not-mega:         mega(1280 and 2560)
// slave reset: 10:               53
// MOSI:        11:               51
// MISO:        12:               50
// SCK:         13:               52 


Yeah, this is a lot simpler than I inittialy thought. But ok, now all i had to do was to check the ATTiny datasheet for its pinout.


Also, in those comments there was reference to three very  useful LEDs:


// Put an LED (with resistor) on the following pins:
// 9: Heartbeat - shows the programmer is running
// 8: Error - Lights up if something goes wrong (use red if that makes sense)
// 7: Programming - In communication with the slave

With those, I can know what the fuck my programmer is doing to the ATTiny. And here is my first prototype:



Now, as everyone's told, i cloned tekstop's Arduino (https://github.com/tekstop/attiny) repository from github branch Arduino1 (dont ask me why that name :-) and included it into the arduino IDE.

After the Arduino IDE setup, I ran a simple LED blinking hello world to check if it was everything ok. This test shown that the tekstop's project weren't configuring the uMCU correctly. After a few googling I discovered that the inittial configuration of the ATTiny were setting the internal clock incorrectly. Applying the following patch apparently fixed the issue.


diff --git a/attiny/boards.txt b/attiny/boards.txt
index 6e74f4e..527d993 100644
--- a/attiny/boards.txt
+++ b/attiny/boards.txt
@@ -123,7 +123,7 @@ attiny13.bootloader.low_fuses=0x7a
 attiny13.bootloader.high_fuses=0xff
 attiny13.upload.maximum_size=1024
 attiny13.build.mcu=attiny13
-attiny13.build.f_cpu=9600000L
+attiny13.build.f_cpu=1200000L
 attiny13.build.core=arduino:arduino
 attiny13.build.variant=tiny8

Adding some todos to this pico project:

- Use an actively maintained repo;
- Build it on a PCB;
- The first burn always return error on the Arduino;
- and others that I need to think :-)

So, this is it. My first post on this experimental blog. Because I want to be cool as these bloggers around the world.


Nenhum comentário:

Postar um comentário