Pages: 1 ... 7 8 [9] 10 11 ... 19   Go Down
Author Topic: core13: An Arduino core for the Attiny13 *testers wanted*  (Read 43885 times)
0 Members and 1 Guest are viewing this topic.
Pennsylvania, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Trying to make sense of it all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


 /\_/\      ARDUINO
((@v@))     CNC
()~|~()

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1729
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

~Tom~

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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
« Last Edit: February 11, 2013, 05:12:38 am by pswag » Logged

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 804
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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
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.
Logged

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!

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
http://arduino.cc/en/Reference/AnalogReference

What's the problem with implementing analogReference()? This is pretty easy, and the T13 can do it. So people can make use of it.
« Last Edit: February 13, 2013, 07:31:31 pm by pswag » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

* wiring.h (2.58 KB - downloaded 11 times.)
* wiring_analog.c (1.16 KB - downloaded 12 times.)
Logged

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 804
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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!

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 804
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Code:
pinMode(pin,INPUT);
digitalWrite(pin,1);
will enable the pullup.
Logged

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!

Denmark
Offline Offline
Edison Member
*
Karma: 36
Posts: 1084
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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:

http://arduino.cc/forum/index.php/topic,123388.msg1033756.html#msg1033756
Logged

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 804
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 03, 2013, 01:38:48 pm by smeezekitty » Logged

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!

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 804
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

New version released!
Logged

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!

Denmark
Offline Offline
Edison Member
*
Karma: 36
Posts: 1084
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is the newest core called 017 ?

I downloaded from the link in the first post in this thread
Logged

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 804
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is the newest core called 017 ?

I downloaded from the link in the first post in this thread
No, the new version is 0.18.
Logged

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!

Pages: 1 ... 7 8 [9] 10 11 ... 19   Go Up
Jump to: