Go Down

Topic: core13: An Arduino core for the Attiny13 *testers wanted* (Read 177532 times) previous topic - next topic

ElectroNick

Thanks, smeezekitty, I'm looking forward to trying what will come out for the slower internal clock speeds.

regarding this tho:
Quote
For millis() I will probably add the proper division to increase accuracy.

I tried to mess with  these lines in the the millis() code in your core:
Code: [Select]
#elif F_CPU == 1000000
x = ovrf / 4;


to make it look more like this (hopefully my math was correct):

Code: [Select]

#elif F_CPU == 1200000 /* 9.6MHz internal oscillator with sys clock divided by 8 (default) */
x = ovrf / 4.687; /*  1,200,000/256/1000  =  4.6875 overflows per millisecond */


And the result was that the compiled sketch became so big that it would no longer fit into the Flash (it added a whole 1kB if my memory serves) . It seems to really-really not like long type instead of int in this case. I'm honestly not sure what can you do about it: unless the clock speed is the exact amount in MHz, dividing it by a fractional number seems to really screw things up.

Pelletta

Simply fantastic, thanks for sharing this project.
I have five Attiny13A and tomorrow morning I will try to use them.
I am not very expert on programming but you if need a tester, you have found it.
Greetings from Italy

ElectroNick


I uploaded a new version with support for 4MHz, 4.8Mhz and better support for 9.6MHz.


Sorry, did not see your latest post before sending mine. I'll try that tonight.
Question though:
what would the boards.txt now look like? I've got so many versions already that I feel like I have to wipe everything and start afresh. Could you make the required boards.txt file a part of the package please?

Cheers!

smeezekitty

Quote

And the result was that the compiled sketch became so big that it would no longer fit into the Flash (it added a whole 1kB if my memory serves) . It seems to really-really not like long type instead of int in this case. I'm honestly not sure what can you do about it: unless the clock speed is the exact amount in MHz, dividing it by a fractional number seems to really screw things up.

Thats because it pulls in the float point emulation library which is about 750 bytes!
You will have to divide by 5 which will still give you an error of less then 10%.
Remember the tolerance of the internal oscillator is only 5-25% tolerance anyway so you cannot really use it for precise timing anyway.
Quote

Simply fantastic, thanks for sharing this project.
I have five Attiny13A and tomorrow morning I will try to use them.
I am not very expert on programming but you if need a tester, you have found it.
Greetings from Italy

Thank you!
Quote

Sorry, did not see your latest post before sending mine. I'll try that tonight.
Question though:
what would the boards.txt now look like? I've got so many versions already that I feel like I have to wipe everything and start afresh. Could you make the required boards.txt file a part of the package please?

Just set F_CPU to equal your clock speed.
To be honest I don't understand boards.txt very well either.
Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

ElectroNick

Code: [Select]
Just set F_CPU to equal your clock speed.
To be honest I don't understand boards.txt very well either.

OK, no prob. I'll try to get through all the clutter and come up with a reasonably clean boards.txt file containing the fuses and F_CPU values needed.  I see that you've added a few F_CPU options in wiring.c millis() function - those will need to be coordinated with the boards.txt file. Also, a proper boards.txt file will be needed to burn the fuses without leaving the Arduino IDE - that would be my personal preference - so I'll have to verify all the fuses I've played with so far.
Cheers!

blackir

Thanks, smeezekitty,
I am blinking some LEDs here using Arduino 1.0 (Windows) with ATTINY13V-10PU, 8-bit microcontroller 10Mhz with 1Kb Flash.

Function delay (1000) which is 1 second duration lasts just over one second but for my use of ATtiny it suits me.
Here is my setup:

The smeezekitty's core had to be located at  "~/sketchbook/hardware/tiny/cores/core13/"

board.txt
Quote

attiny13.name=Attiny13
attiny13.upload.using=arduino:arduinoisp
attiny13.upload.maximum_size=1024
attiny13.upload.speed=19200
attiny13.bootloader.low_fuses=0x7B
attiny13.bootloader.high_fuses=0xFF
attiny13.bootloader.path=empty
attiny13.bootloader.file=empty
attiny13.bootloader.unlock_bits=0xFF
attiny13.bootloader.lock_bits=0xFF
attiny13.build.mcu=attiny13
attiny13.build.f_cpu=9600000
attiny13.build.core=core13



~/sketchbook/hardware/arduino/codes/core13/Arduino.h
Quote

#ifndef Arduino_h
#define Arduino_h
#include <WProgram.h>
#endif



I noticed a problem in wiring.c, ";" was missing on line 32.
Quote

#elif F_CPU == 9600000
x = ovrf / 37;


Although technically a 10MHZ crystal is, I used the config to 9.6MHZ, it's probably just that the latency in the function delay ().
Avrdude back when a problem on behalf of the microcontroller, I had to change the line to put attiny13.build.mcu ATTINY13 the end, as above.

Can you open a page on sourceforge?


Great job, smeezekitty!

ElectroNick

I played with Arduino 1.0 some more and then summarized the findings in a blog post here:  http://elabz.com/arduino-shrunk-how-to-use-attiny13-with-arduino-ide/ There's a slightly different version of boards.txt file there.
In my case I simply copied the Arduino.h file from another core to make it version 1.0 - compatible ( it has the same content as blackir's though) - this was the only thing needed for 1.0 compatibility. In fact, I haven't noticed that many differences between 0022 and 1.0 while programming a "normal" Arduino. For ATtiny however, version 1.0 is much more comfortable because all functions specific to an MCU without bootloader are implemented inside the menus and there's no need to leave the IDE to do anything - burn fuses or load via programmer.

smeezekitty, if you haven't switched yet, definitely try 1.0.  Even just in general,  since we are talking about an open source, free software, I don't know if it makes any sense to support previous versions when it's so easy to upgrade (they can both co-exist).

smeezekitty


Thanks, smeezekitty,
I am blinking some LEDs here using Arduino 1.0 (Windows) with ATTINY13V-10PU, 8-bit microcontroller 10Mhz with 1Kb Flash.

Function delay (1000) which is 1 second duration lasts just over one second but for my use of ATtiny it suits me.
Here is my setup:

Thats because the the avr-libc delay function is too slow. I think I will re-implement it soon.
Quote

I noticed a problem in wiring.c, ";" was missing on line 32.
Quote

#elif F_CPU == 9600000
x = ovrf / 37;


Fixed in next release.
Quote

Although technically a 10MHZ crystal is, I used the config to 9.6MHZ, it's probably just that the latency in the function delay ().
Avrdude back when a problem on behalf of the microcontroller, I had to change the line to put attiny13.build.mcu ATTINY13 the end, as above.

I added a provision that should make millis() slightly more accurate on 10 and 12mhz crystals.
delayMicroseconds() will still be somewhat off which is *very* difficult to fix because I can only device and multiply by factors of two because I am using binary shifts for speed.
Quote

Can you open a page on sourceforge?

I was going to but got sidetracked. I think I may do that soon.
Quote

Great job, smeezekitty!

:)
Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

smeezekitty

#38
Mar 07, 2012, 12:51 am Last Edit: Mar 07, 2012, 04:23 am by smeezekitty Reason: 1

I played with Arduino 1.0 some more and then summarized the findings in a blog post here:  http://elabz.com/arduino-shrunk-how-to-use-attiny13-with-arduino-ide/ There's a slightly different version of boards.txt file there.

One thing is a bit wrong bit wrong:
Quote

So far I came across three different sets of libraries suitable for programming of ATtiny13 microcontrollers:

Actually, my core is the only one that supports the Attiny13. The other only support attiny25 and better from what I can tell.
It should be
Quote

So far I came across three different sets of libraries suitable for programming of ATtiny microcontrollers:

Quote

In my case I simply copied the Arduino.h file from another core to make it version 1.0 - compatible ( it has the same content as blackir's though) - this was the only thing needed for 1.0 compatibility.

This should be fixed in the newest release
Quote

This should be In fact, I haven't noticed that many differences between 0022 and 1.0 while programming a "normal" Arduino. For ATtiny however, version 1.0 is much more comfortable because all functions specific to an MCU without bootloader are implemented inside the menus and there's no need to leave the IDE to do anything - burn fuses or load via programmer.

smeezekitty, if you haven't switched yet, definitely try 1.0.  Even just in general,  since we are talking about an open source, free software, I don't know if it makes any sense to support previous versions when it's so easy to upgrade (they can both co-exist).

I guess I have heard too many horror stories

New release!
Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

smeezekitty

Inital source-forge page created:https://sourceforge.net/projects/ard-core13/
Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

ElectroNick


One thing is a bit wrong bit wrong:
Quote

So far I came across three different sets of libraries suitable for programming of ATtiny13 microcontrollers:

Actually, my core is the only one that supports the Attiny13. The other only support attiny25 and better from what I can tell.
It should be
Quote

So far I came across three different sets of libraries suitable for programming of ATtiny microcontrollers:

Good catch, smeezekitty. Yes, the wording of that paragraph is wrong. Damellis'es ATtiny core can actually be adapted for ATtiny13 and he posted a mini how-to on that. But the other one seems to have abandoned the 13 in exchange for support of the SoftwareSerial library (useful for chips with no UART). I shall go change that!   :smiley-mr-green:

blackir

#41
Mar 07, 2012, 10:03 am Last Edit: Mar 07, 2012, 07:10 pm by blackir Reason: 1
Hy,

Thank you for changes.
I noticed a problem in wiring.c (core13_0_135), ";" was missing on line 28.
Quote

Correction :
#elif F_CPU == 4000000
x = ovrf / 16;


I noticed a problem in wiring.c (core13_0_135), "12000000" was replaced by "10000000" on line 58.
Quote

Correction :
#if F_CPU == 16000000 || F_CPU == 12000000


After corrections, core13_0_135 work well.

Thanks, smeezekitty!

Bobnova

Seeing this makes me very happy, now I can order some incredibly cheap chips to play with.
Thank you!

smeezekitty


Hy,

Thank you for changes.
I noticed a problem in wiring.c (core13_0_135), ";" was missing on line 28.
Quote

Correction :
#elif F_CPU == 4000000
x = ovrf / 16;


I noticed a problem in wiring.c (core13_0_135), "12000000" was replaced by "10000000" on line 58.
Quote

Correction :
#if F_CPU == 16000000 || F_CPU == 12000000


After corrections, core13_0_135 work well.

Thanks, smeezekitty!

To be honest, I never compiled this for speeds other then 128khz and 1Mhz so those errors are hard to find.
Quote

Seeing this makes me very happy, now I can order some incredibly cheap chips to play with.
Thank you!

Thats primarily why I started this project.
Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

blackir

hello,

I found a bookstore that uses a library ATTINY13 for ATtiny 8.
I forwarded this can still be useful:

located at  "~/sketchbook/hardware/attiny/"

~/sketchbook/hardware/attiny/board.txt
Quote

attiny13.name=ATtiny13 (internal 9.6 MHz clock)
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.core=arduino:arduino
attiny13.build.variant=tiny8


~/sketchbook/hardware/attiny/variants/tiny8/pins_arduino.h
Quote

/*
  pins_arduino.c - pin definitions for the Arduino board
  Part of Arduino / Wiring Lite

  Copyright (c) 2005 David A. Mellis

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General
  Public License along with this library; if not, write to the
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  Boston, MA  02111-1307  USA

  $Id: pins_arduino.c 565 2009-03-25 10:50:00Z dmellis $

  Modified 28-08-2009 for attiny84 R.Wiersma
  Modified 09-10-2009 for attiny45 A.Saporetti
*/

#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <avr/pgmspace.h>

// ATMEL ATTINY45 / ARDUINO
//
//                  +-\/-+
// Ain0 (D 5) PB5  1|    |8  Vcc
// Ain3 (D 3) PB3  2|    |7  PB2 (D 2) Ain1
// Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1
//            GND  4|    |5  PB0 (D 0) pwm0
//                  +----+

#define digitalPinToPCICR(p)    ( ((p) >= 0 && (p) <= 4) ? (&GIMSK) : ((uint8_t *)0) )
#define digitalPinToPCICRbit(p) ( PCIE )
#define digitalPinToPCMSK(p)    ( ((p) <= 4) ? (&PCMSK) : ((uint8_t *)0) )
#define digitalPinToPCMSKbit(p) ( (p) )

#ifdef ARDUINO_MAIN

// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing) tiny45 only port B
const uint16_t PROGMEM port_to_mode_PGM[] = {
   NOT_A_PORT,
   NOT_A_PORT,
   (uint16_t) &DDRB,
};

const uint16_t PROGMEM port_to_output_PGM[] = {
   NOT_A_PORT,
   NOT_A_PORT,
   (uint16_t) &PORTB,
};

const uint16_t PROGMEM port_to_input_PGM[] = {
   NOT_A_PIN,
   NOT_A_PIN,
   (uint16_t) &PINB,
};

const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
   PB, /* 0 */
   PB,
   PB,
   PB,
   PB,
   PB, // 5
};

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
   _BV(0), /* 0, port B */
   _BV(1),
   _BV(2),
   _BV(3), /* 3, port B */
   _BV(4),
   _BV(5),
};

const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
   TIMER0A, /* OC0A */
   TIMER0B,
   NOT_ON_TIMER,
   NOT_ON_TIMER,
   NOT_ON_TIMER,
   NOT_ON_TIMER,
};

#endif

#endif


bye

Go Up