core13: An Arduino core for the Attiny13 *testers wanted*

smeezekitty:
This

attiny13at9m.name=ATtiny13 @ 9.6 Mhz

attiny13at9m.bootloader.low_fuses=0x7A
attiny13at9m.bootloader.high_fuses=0xff
attiny13at9m.upload.maximum_size=1024
attiny13at9m.build.mcu=attiny13
attiny13at9m.build.f_cpu=9600000
attiny13at9m.build.core=core13



should make it run at 9.6MHz. If this gives errors then I am at a loss.
It would be kind of nice if Arduino would develop something easier then boards.txt.

That one loads fine.
Now I'm off to figure out "unsigned long pulseIn_new"

Now I'm off to figure out "unsigned long pulseIn_new"

Simply put it at the top of your source file and replace all uses of pulseIn with pulseIn_new.
The new version might fix a possible bug. If it works better I will merge it with the core in the next version.
Please understand this is prealpha software and in the early testing stages so tons of bugs is to be expected.

I'm really looking forward to try this new core, but how should I connect the attiny13 to the arduino? is there some kind of connection diagram out there? and do I need to use arduinoISP to program it, an arduino with the 328p installed(or not installed), or can I use a FTDI breakout.

If someone have the answer it would be great! :smiley:

hansibull:
but how should I connect the attiny13 to the arduino? is there some kind of connection diagram out there?

Wire it just like this. http://hlt.media.mit.edu/?p=1229 But ignore the instructions about installing the 45/85 core.

and do I need to use arduinoISP to program it

Yes.

, an arduino with the 328p installed(or not installed), or can I use a FTDI breakout.

Yes. Use an Arduino with the Atmega installed and the arduinoISP loaded. An FTDI board will not work since the attiny13 does not support serial.

Hi,
I just wanted to test your core13 sources on my platform here.
I run Ubuntu 12.10 with Arduino 1.0.1 and installed your version 16 (core13_016.zip).
As a programmer I use USBtiny and got that programmer into boards.txt.
It compiles well with no errors.

However, I get the following error from avrdude while uploading the blink sketch:

avrdude: Expected signature for ATtiny13 is 1E 90 07

  • Double check chip, or use -F to override this check.*

Do I have burn some fuses beforehand ?

When I run avrdude with 'avrdude -c usbtiny -p t2313' I get the following answer:

avrdude: Device signature = 0x1e910a
avrdude: safemode: Fuses OK

What does that 'device signature' mean and why is it different from the 'expected signature' ?

Thanks for your help.

Regards
AgeBee

An attiny2313 is not an attiny13. Thus their unique device signatures don't match.

AgeBee:
Hi,
I just wanted to test your core13 sources on my platform here.
I run Ubuntu 12.10 with Arduino 1.0.1 and installed your version 16 (core13_016.zip).
As a programmer I use USBtiny and got that programmer into boards.txt.
It compiles well with no errors.

However, I get the following error from avrdude while uploading the blink sketch:

avrdude: Expected signature for ATtiny13 is 1E 90 07

  • Double check chip, or use -F to override this check.*

"Tom Carpenter" is correct. The attiny2313 is not an attiny13.
Also, core13 will only work on 8 pin devices.
Google Code Archive - Long-term storage for Google Code Project Hosting. probably will work with an attiny2313.

Also I have been out of down and had two(!) computer failures so support and development is delayed.

Hello,

I've just started using the arduino and successfully uploaded the blinker to my attiny13a following:

and
http://hlt.media.mit.edu/?p=1229

I've ran into the default fuses problem and fixed it by "installing bootloader" in the IDE but now I have a question that wasn't answered around here:

Can you use all the pins on this device (the reset pin, too) without a bootloader?! (my reading from various forums says NO, not without setting the fuse so the pin is no longer RESET and needing a high-voltage programmer to reprogram the device)

Can you help me understand if and how this works?

mrares:
Can you use all the pins on this device (the reset pin, too) without a bootloader?! (my reading from various forums says NO, not without setting the fuse so the pin is no longer RESET and needing a high-voltage programmer to reprogram the device)

"Burn Bootloader" as far as ATtiny13 and other chips burned using a programmer are concerned, is a euphemism. There's no bootloader (and no need for one either) - all this Arduino IDE function does is to burn proper configuration fuses so the MCU operates using the right clock frequency and so your time-dependent programs, such as the LED blinker, work properly. There are plenty of other configuration variables set by the config fuses but the timing is probably most important from the practical stand point - most others are left on defaults.

You cannot use the Reset pin if you're planning to re-flash the MCU using an ICSP programmer. Unless you have a high-voltage programmer, just consider ATtiny13 a 5xI/O MCU - makes development easier.

Got it! Once reading the spec of the attiny13a it looks like with a bit of elbow grease and a 12V power supply one can reset the fuses off a chip with the help of an Uno and a custom sketch.

Is it possible to write the fuses from within the code on the chip? (eg: set the reset pin enabled or disabled from your sketch, say... on a spi command received)

mrares:
Is it possible to write the fuses from within the code on the chip? (eg: set the reset pin enabled or disabled from your sketch, say... on a spi command received)

No, you can't. The device can only be programmed when held in Reset (ISP), or with a high voltage programmer.
Furthermore, if the reset pin is disabled, then the ISP won't work as there is no way for it to hold the chip in reset.

ADMUX = (1<<REFS0) | pin & 7; //Setup ADC

Hi,

the analog mux has only 4 channels on T13. Ain't it better giving the user the ability to select the analog reference?
What about this:

ADMUX = ADMUX & _BV(REFS0) | pin & 3; //Setup ADC, preserve REFS0

and implement analogReference():

void analogReference(uint8_t mode){

  • if(mode==INTERNAL)*
  • ADMUX |= _BV(REFS0)*
  • else*
  • ADMUX &= ~_BV(REFS0)*
    }

Cheers, Peter

pswag:
ADMUX = (1<<REFS0) | pin & 7; //Setup ADC

Hi,

the analog mux has only 4 channels on T13. Ain't it better giving the user the ability to select the analog reference?
What about this:

ADMUX = ADMUX & _BV(REFS0) | pin & 3; //Setup ADC, preserve REFS0

and implement analogReference():

void analogReference(uint8_t mode){

  • if(mode==INTERNAL)*
  • ADMUX |= _BV(REFS0)*
  • else*
  • ADMUX &= ~_BV(REFS0)*
    }

Cheers, Peter

To be quite honest, I did not realize the '13 had an analog reference other than +V. The "& 7" is a bug. I will fix it in the next release.

I still do not really see the point in supporting analogReference.

I am wondering why analogRead() explicitely sticks the REFS0 bit to 1 every time it is called (1<<REFS0), which selects the INTERNAL 1V1 reference, hence A/D range is limited to an input voltage from 0 to 1.1 V. This is no good.

However the Arduino uses 0 to VCC by default.

The datasheet says:
0 VCC used as analog reference. -> #define DEFAULT 0
1 Internal Voltage Reference. -> #define INTERNAL 1

Users would actually not expect that analogRead() was setting the analog reference.
analogReference() is intended for doing the job.

#defines are provided in wiring.h

See also

What's the problem with implementing analogReference()? This is pretty easy, and the T13 can do it. So people can make use of it.

I'd like to share the modifications I have already done to your code.

wiring.h (2.58 KB)

wiring_analog.c (1.16 KB)

pswag:
I am wondering why analogRead() explicitely sticks the REFS0 bit to 1 every time it is called (1<<REFS0), which selects the INTERNAL 1V1 reference, hence A/D range is limited to an input voltage from 0 to 1.1 V. This is no good.

Oh yikes. Thanks for catching that. It is a bug.
These things are hard to debug without a Serial interface.

Although quite honestly I was not even aware of the 1.1V reference. I thought that was only on the higher end chips.

I will evaluate your changes and determine if it is worth including. Please standby.

A small feature request: Could you add PinMode(pin,INPUT_PULLUP)? This makes simple buttons easier!

Somnitec:
A small feature request: Could you add PinMode(pin,INPUT_PULLUP)? This makes simple buttons easier!

I could. As it is, it uses Arduino 022 style so

pinMode(pin,INPUT);
digitalWrite(pin,1);

will enable the pullup.

These things are hard to debug without a Serial interface.

You might be interested in this:

Using Coding Badly's TinyISP and knockbang library, it is posiible to get debug output from a tiny13 and your core:

You know, oddly enough I created an synchronous serial debugging system for the Attiny13 but I got fed up of flashing the Arduino between the ISP sketch and the serial receive sketch.

I will look at that. Thanks.

Side note: Version 0.18 is in progress.