Go Down

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

#### smeezekitty

#75
##### Aug 14, 2012, 07:42 pm

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 */`

If you need to divide by 4.687 without using floating point, you can use any of the "best rational approximations" of the number, to the precision required:

4.687 = 5 ± 6.7%
4.687 = 14/3 ± 0.4%
4.687 = 75/16 ± 0.01%
4.687 = 539/115 ± 0.001%
. . .

For example, choosing the ±0.01% value:

x = ovrf * 16 / 75;

Just remember to do the multiplication before the division, because the division truncates, and not to use too large a multiplication as to cause overflow. (If times 16 is too much in this case, you could use 14/3 ± 0.4% and only multiply by 3.)

I have attached a Python program to compute these fractions for a given floating number, based on this example.

smeezekitty: maybe you could use this trick to increase the precision of millis()?

Note you do have to watch flash use very carefully to maximize the space available for the main program.
6.7% is not really an unreasonable for an attiny chip and obviously not the biggest error.
Nonetheless I will probably try your method while watching flash usage.
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!

#### gizmoDave

#76
##### Aug 15, 2012, 05:09 pm
I have read this and several other posts on programing an ATtiny13 (13A in my case).
I have owned an Arduino Uno R3 for about a week so be prepared for nube questions. I have been searching the web and have seen several tutorials that refer to using the arduino as an ISP but then go on to use something else to actually program the ATtiny so I am a bit lost. If there is aArduino ISP ATtiny programing for dummies pleas provide a link
I have the latest version of core 13_014 installed as follows C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13. I have seen at least three different boards.txt modifications in this thread, which one should I use???
I see use a bootloader then statements that the ATtiny can't

I understand the pin assignments have to be changed to match the ATtiny but at the moment I need to figure out how to get the ISP to communicate with the MCU without generating numerous error messages. this is what I get when attempting upload arduinoISP from the examples

C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp: In function 'int main()':
C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp:11: error: 'init' was not declared in this scope
C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp:12: error: 'setup' was not declared in this scope
C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp:13: error: 'loop' was not declared in this scope

Attempting to run tools/burn bootloader produces

avrdude: stk500_getsync(): not in sync: resp=0x00

.1uf capacitor between reset and ground does not have any effect.

Here is the code I have hacked and would like to have my ATtiny execute, strobes and anti collision lights for an RC aircraft.
Code: [Select]
` /*  Blink  Turns on an LED on for three 250 ms blinks, then off for one second, repeatedly.   This example code is in the public domain. */ // give it a name:int led = 13;int ledpin = 10;int fadePin = 9;// the setup routine runs once when you press reset:void setup() {                  // initialize the digital pin as an output.  pinMode(led, OUTPUT);    pinMode(ledpin, OUTPUT);  }// the loop routine runs over and over again forever:void loop() {     digitalWrite(led, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for a second  digitalWrite(led, LOW);   digitalWrite(ledpin, HIGH);  // turn the LED off by making the voltage LOW  delay(100);         digitalWrite(ledpin, LOW);   digitalWrite(led, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for 14 second  digitalWrite(led, LOW);  digitalWrite(ledpin, HIGH);  // turn the LED off by making the voltage LOW  delay(100);   digitalWrite(ledpin, LOW);   digitalWrite(led, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for 1/4 second  digitalWrite(led, LOW);  digitalWrite(ledpin, HIGH);  delay(100);  digitalWrite(ledpin, LOW);   // turn the LED off by making the voltage LOW                               // turn the LED off by making the voltage LOW  delay(100);                 // wait for a second    for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=10) {     // sets the value (range from 0 to 255):    analogWrite(fadePin, fadeValue);             // wait for 30 milliseconds to see the dimming effect        delay(40);                              }   // fade out from max to min in increments of 5 points:  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {     // sets the value (range from 0 to 255):    analogWrite(fadePin, fadeValue);             // wait for 30 milliseconds to see the dimming effect        delay(20);                              } } `

#### gizmoDave

#77
##### Aug 15, 2012, 07:16 pmLast Edit: Aug 15, 2012, 10:16 pm by gizmoDave Reason: 1
After hours spent getting errors I have discovered that using the files in core 13_014 and core 13_015 do not work with my UNO R3. Something in the instruction set points to invalid functions causing the Uno to not accept any new instructions. I have modified #include "WProgram.h" per the instructions in  Read this before posting a programming question ...  still no luck.
I have verified this issue by deleting the core13 folder and uploading the blink example and my altered version posted above which would not upload previously. Now both sketches are working just fine on the Uno and bread board with resistors & LEDs installed.
Can anyone verify that the file set provided actually works with an Uno R3 with an ATMEGA328P-PU and software ver arduino-1.0.1 or provide instructions on how to modify the code to work properly?
I am running Win Vista home basic with SP2

#### smeezekitty

#78
##### Aug 15, 2012, 10:33 pmLast Edit: Aug 15, 2012, 10:37 pm by smeezekitty Reason: 1
Let me first suggest going here: http://elabz.com/arduino-shrunk-how-to-use-attiny13-with-arduino-ide/

I have read this and several other posts on programing an ATtiny13 (13A in my case).
I have owned an Arduino Uno R3 for about a week so be prepared for nube questions. I have been searching the web and have seen several tutorials that refer to using the arduino as an ISP but then go on to use something else to actually program the ATtiny so I am a bit lost. If there is aArduino ISP ATtiny programing for dummies pleas provide a link

I haven't had any problems using my Duemillanove to program an Attiny13A and I have head that the Uno R3 works fine as an ISP but I do not have one to try it.
Quote

I have the latest version of core 13_014 installed as follows C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13. I have seen at least three different boards.txt modifications in this thread, which one should I use???

The boards.txt file is a confusing creature.
This works for me:
Code: [Select]
`attiny13.name=Attiny 13A standaloneattiny13.upload.using=arduino:arduinoispattiny13.upload.maximum_size=1024attiny13.upload.speed=19200attiny13.bootloader.low_fuses=0x6Aattiny13.bootloader.high_fuses=0xFFattiny13.bootloader.path=emptyattiny13.bootloader.file=emptyattiny13.bootloader.unlock_bits=0xFFattiny13.bootloader.lock_bits=0xFFattiny13.build.mcu=attiny13attiny13.build.f_cpu=9600000Lattiny13.build.core=core13`
Quote

I see use a bootloader then statements that the ATtiny can't

The attiny13 is too small to support a bootloader so the upload bootloader command only burns the fuses. It should not be strictly necessary but it may run the wrong clock speed if you do not.
Quote

I understand the pin assignments have to be changed to match the ATtiny but at the moment I need to figure out how to get the ISP to communicate with the MCU without generating numerous error messages.

Changing pin assignments is trivial once it is working.
Quote

this is what I get when attempting upload arduinoISP from the example

C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp: In function 'int main()':
C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp:11: error: 'init' was not declared in this scope
C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp:12: error: 'setup' was not declared in this scope
C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp:13: error: 'loop' was not declared in this scope

The files on your system should be located in C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\core13.
You have them one directory too deep.
Quote

Attempting to run tools/burn bootloader produces

avrdude: stk500_getsync(): not in sync: resp=0x00

Ensure the ArduinoISP sketch is installed properly and recheck your wiring. In any case, we will deal with these errors once we get rid of the compiler errors.
Quote

.1uf capacitor between reset and ground does not have any effect.

Quote

Here is the code I have hacked and would like to have my ATtiny execute, strobes and anti collision lights for an RC aircraft.
Code: [Select]
` /*  Blink  Turns on an LED on for three 250 ms blinks, then off for one second, repeatedly.  This example code is in the public domain. */ // give it a name:int led = 13;int ledpin = 10;int fadePin = 9;// the setup routine runs once when you press reset:void setup() {                  // initialize the digital pin as an output.  pinMode(led, OUTPUT);    pinMode(ledpin, OUTPUT);  }// the loop routine runs over and over again forever:void loop() {    digitalWrite(led, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for a second  digitalWrite(led, LOW);  digitalWrite(ledpin, HIGH);  // turn the LED off by making the voltage LOW  delay(100);        digitalWrite(ledpin, LOW);  digitalWrite(led, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for 14 second  digitalWrite(led, LOW);  digitalWrite(ledpin, HIGH);  // turn the LED off by making the voltage LOW  delay(100);  digitalWrite(ledpin, LOW);  digitalWrite(led, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for 1/4 second  digitalWrite(led, LOW);  digitalWrite(ledpin, HIGH);  delay(100);  digitalWrite(ledpin, LOW);   // turn the LED off by making the voltage LOW                               // turn the LED off by making the voltage LOW  delay(100);                 // wait for a second    for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=10) {    // sets the value (range from 0 to 255):    analogWrite(fadePin, fadeValue);            // wait for 30 milliseconds to see the dimming effect        delay(40);                              }  // fade out from max to min in increments of 5 points:  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {    // sets the value (range from 0 to 255):    analogWrite(fadePin, fadeValue);            // wait for 30 milliseconds to see the dimming effect        delay(20);                              } } `

That uses the wrong pins so the attiny will not do anything but this should be addressed after the other errors are addressed.
Quote

After hours wasted I have discovered that using the files in core 13_014 do not work with my UNO R3. Something in the instruction set points to invalid functions causing the Uno to not accept any new instructions.

This is most likely because of the wrong directory structure.
Quote

Can anyone verify that the file set provided actually works with an Uno R3 with an ATMEGA328P-PU and software ver arduino-1.0.1 or provide instructions on how to modify the code to work properly? I need the ATtiny13 programmed to run this sketch as size and weight are an issue for my project.

I can verify that the file set works on Arduino-1.0.1 but cannot verify it works on the Uno since I do not have one. I do not see any reason why it would not work though.
Quote

I am running Win Vista home basic with SP2

Windows Vista SP1 here but it should not matter much.

Also: It is very important that the correct board be selected
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!

#### gizmoDave

#79
##### Aug 16, 2012, 04:06 am

Let me first suggest going here: http://elabz.com/arduino-shrunk-how-to-use-attiny13-with-arduino-ide/

I have read this and several other posts on programing an ATtiny13 (13A in my case).
I have owned an Arduino Uno R3 for about a week so be prepared for nube questions. I have been searching the web and have seen several tutorials that refer to using the arduino as an ISP but then go on to use something else to actually program the ATtiny so I am a bit lost. If there is aArduino ISP ATtiny programing for dummies pleas provide a link

I managed to get to step 8 in the EZlab link before I got error "avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny13
I searched and found this error can be ignored?
Quote
Quote
I haven't had any problems using my Duemillanove to program an Attiny13A and I have head that the Uno R3 works fine as an ISP but I do not have one to try it.

Quote

I have the latest version of core 13_014 installed as follows C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13. I have seen at least three different boards.txt modifications in this thread, which one should I use???

Quote
The boards.txt file is a confusing creature.
This works for me:

Code: [Select]
`attiny13.name=Attiny 13A standaloneattiny13.upload.using=arduino:arduinoispattiny13.upload.maximum_size=1024attiny13.upload.speed=19200attiny13.bootloader.low_fuses=0x6Aattiny13.bootloader.high_fuses=0xFFattiny13.bootloader.path=emptyattiny13.bootloader.file=emptyattiny13.bootloader.unlock_bits=0xFFattiny13.bootloader.lock_bits=0xFFattiny13.build.mcu=attiny13attiny13.build.f_cpu=9600000Lattiny13.build.core=core13`

I got more errors using your example ended up using the one from EZlab,it produced less errors
Quote
Quote

I see use a bootloader then statements that the ATtiny can't

The attiny13 is too small to support a bootloader so the upload bootloader command only burns the fuses. It should not be strictly necessary but it may run the wrong clock speed if you do not.
Quote

I understand the pin assignments have to be changed to match the ATtiny but at the moment I need to figure out how to get the ISP to communicate with the MCU without generating numerous error messages.

Changing pin assignments is trivial once it is working.
Quote

this is what I get when attempting upload arduinoISP from the example

C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp: In function 'int main()':
C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp:11: error: 'init' was not declared in this scope
C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp:12: error: 'setup' was not declared in this scope
C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino\core13\main.cpp:13: error: 'loop' was not declared in this scope

Quote
The files on your system should be located in C:\arduino\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\core13.
You have them one directory too deep.

Thanks I missed that one completely, reloaded with the correct directory structure and things seem to be working much better.
Quote
Quote

Attempting to run tools/burn bootloader produces

avrdude: stk500_getsync(): not in sync: resp=0x00

Ensure the ArduinoISP sketch is installed properly and recheck your wiring. In any case, we will deal with these errors once we get rid of the compiler errors.
Quote

.1uf capacitor between reset and ground does not have any effect.

Quote

Here is the code I have hacked and would like to have my ATtiny execute, strobes and anti collision lights for an RC aircraft.
Code: [Select]
` /*  Blink  Turns on an LED on for three 250 ms blinks, then off for one second, repeatedly.  This example code is in the public domain. */ int led = PB3;int ledpin = PB4;int fadePin = PB1;// the setup routine runs once when you press reset:void setup() {                  // initialize the digital pin as an output.  pinMode(PB3, OUTPUT);    pinMode(PB4, OUTPUT);  }// the loop routine runs over and over again forever:void loop() {     digitalWrite(PB3, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for a second  digitalWrite(PB3, LOW);   digitalWrite(PB4, HIGH);  // turn the LED off by making the voltage LOW  delay(100);         digitalWrite(PB4, LOW);   digitalWrite(PB3, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for 14 second  digitalWrite(PB3, LOW);  digitalWrite(PB4, HIGH);  // turn the LED off by making the voltage LOW  delay(100);   digitalWrite(PB4, LOW);   digitalWrite(led, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for 1/4 second  digitalWrite(PB3, LOW);  digitalWrite(PB4, HIGH);  delay(100);  digitalWrite(PB4, LOW);   // turn the LED off by making the voltage LOW                               // turn the LED off by making the voltage LOW  delay(100);                 // wait for a second    for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=10) {     // sets the value (range from 0 to 255):    analogWrite(fadePin, fadeValue);             // wait for 30 milliseconds to see the dimming effect        delay(40);                              }   // fade out from max to min in increments of 5 points:  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {     // sets the value (range from 0 to 255):    analogWrite(fadePin, fadeValue);             // wait for 30 milliseconds to see the dimming effect        delay(20);                              } }} `

Quote
That uses the wrong pins so the attiny will not do anything but this should be addressed after the other errors are addressed.

Changed pin assignments to PB3,PB4,&PB1
Quote
Quote

After hours wasted I have discovered that using the files in core 13_014 do not work with my UNO R3. Something in the instruction set points to invalid functions causing the Uno to not accept any new instructions.

Quote
This is most likely because of the wrong directory structure.

Fixed structure and most of the errors went away
Quote
Quote

Can anyone verify that the file set provided actually works with an Uno R3 with an ATMEGA328P-PU and software ver arduino-1.0.1 or provide instructions on how to modify the code to work properly? I need the ATtiny13 programmed to run this sketch as size and weight are an issue for my project.

I can verify that the file set works on Arduino-1.0.1 but cannot verify it works on the Uno since I do not have one. I do not see any reason why it would not work though.
Quote

I am running Win Vista home basic with SP2

Windows Vista SP1 here but it should not matter much.

Also: It is very important that the correct board be selected
[/quote]

I changed the code above to something I think the ATtiny will be able to use
opened the new sketch and hit the verify icon and get the following error

C:\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\core13\main.cpp:8: error: expected constructor, destructor, or type conversion before '.' token

I don't even have a clue to search for an explanation for this error    I looked for a misplaced . but don't see one.

#### smeezekitty

#80
##### Aug 16, 2012, 05:48 am

I managed to get to step 8 in the EZlab link before I got error "avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny13
I searched and found this error can be ignored?

This "error" is totally irrelevant and must be ignored. For some odd reason AVRDUDE complains when you haven't defined the PAGEL and BS2 signals even though the attiny series processors do not support this. It will upload without issues regardless though.
Quote
Thanks I missed that one completely, reloaded with the correct directory structure and things seem to be working much better.

That it a good sign.

Quote

I changed the code above to something I think the ATtiny will be able to use
opened the new sketch and hit the verify icon and get the following error

C:\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\core13\main.cpp:8: error: expected constructor, destructor, or type conversion before '.' token

I don't even have a clue to search for an explanation for this error    I looked for a misplaced . but don't see one.

That is a weird error. Can you post the file? (It shouldn't be very long) Also ensure the notice block at the top is commented out.
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!

#### gizmoDave

#81
##### Aug 16, 2012, 02:03 pm
Code: [Select]
`/*  Blink  Turns on an LED on for three 250 ms blinks, then off for one second, repeatedly.   This example code is in the public domain. */ // give it a name:int led = PB3;int ledpin = PB4;int fadePin = PB1;// the setup routine runs once when you press reset:void setup() {                  // initialize the digital pin as an output.  pinMode(PB3, OUTPUT);    pinMode(PB4, OUTPUT);  }// the loop routine runs over and over again forever:void loop() {     digitalWrite(PB3, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for a second  digitalWrite(PB3, LOW);   digitalWrite(PB4, HIGH);  // turn the LED off by making the voltage LOW  delay(100);         digitalWrite(PB4, LOW);   digitalWrite(PB3, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for 14 second  digitalWrite(PB3, LOW);  digitalWrite(PB4, HIGH);  // turn the LED off by making the voltage LOW  delay(100);   digitalWrite(PB4, LOW);   digitalWrite(led, HIGH);     // turn the LED on (HIGH is the voltage level)  delay(100);                  // wait for 1/4 second  digitalWrite(PB3, LOW);  digitalWrite(PB4, HIGH);  delay(100);  digitalWrite(PB4, LOW);   // turn the LED off by making the voltage LOW                               // turn the LED off by making the voltage LOW  delay(100);                 // wait for a second    for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=10) {     // sets the value (range from 0 to 255):    analogWrite(fadePin, fadeValue);             // wait for 30 milliseconds to see the dimming effect        delay(40);                              }   // fade out from max to min in increments of 5 points:  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {     // sets the value (range from 0 to 255):    analogWrite(fadePin, fadeValue);             // wait for 30 milliseconds to see the dimming effect        delay(20);                              } }`

Here is the file specifically called out in the error message:
C:\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\core13\main.cpp:8: error: expected constructor, destructor, or type conversion before '.' token
Code: [Select]
`/**** Core13 ***Arduino core designed for Attiny13 and similar devicesNO WARRANTEE OR GUARANTEES!Written by John "smeezekitty" You are free to use, redistribute and modify at will EXCEPT IF MARKED OTHERWISE IN A PARTICULAR SOURCE FILE!Version 0.14*/Arduino.hint main(){ init(); //Call init routine setup(); //Call user provided setup() while(1){loop();} //Continuiously call user provided loop()}`

Is ti possible that I have bricked the ATtiny and that is now causing strange errors?

#### Tom Carpenter

#82
##### Aug 16, 2012, 02:10 pmLast Edit: Aug 16, 2012, 02:13 pm by Tom Carpenter Reason: 1
Code: [Select]
`/**** Core13 ***Arduino core designed for Attiny13 and similar devicesNO WARRANTEE OR GUARANTEES!Written by John "smeezekitty" You are free to use, redistribute and modify at will EXCEPT IF MARKED OTHERWISE IN A PARTICULAR SOURCE FILE!Version 0.14*/Arduino.hint main(){ init(); //Call init routine setup(); //Call user provided setup() while(1){loop();} //Continuiously call user provided loop()}`

should be:
Code: [Select]
`/**** Core13 ***Arduino core designed for Attiny13 and similar devicesNO WARRANTEE OR GUARANTEES!Written by John "smeezekitty" You are free to use, redistribute and modify at will EXCEPT IF MARKED OTHERWISE IN A PARTICULAR SOURCE FILE!Version 0.14*/#include "Arduino.h"int main(){ init(); //Call init routine setup(); //Call user provided setup() while(1){loop();} //Continuiously call user provided loop()}`

The error is essentially saying that it can't find a class named 'Arduino' with member 'h'. It is there because the line "*/Arduino.h" is not put inside the #include statement like it should be.
~Tom~

#### gizmoDave

#83
##### Aug 16, 2012, 06:05 pm
Thanks Tom,
Iwill make the required adjustment the code and program some chips when I get home
Thanks to John "smeezekitty" for all the assistance and work on the code to allow us to program these chips.

#### gizmoDave

#84
##### Aug 17, 2012, 02:47 am
Thanks again guys, I have my first ATtiny13 programmed and blinking away

#### smeezekitty

#85
##### Aug 22, 2012, 03:18 am
***Version 0.16 released***
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!

#### gizmoDave

#86
##### Aug 23, 2012, 02:37 pm
Ver 16 downloaded, hopefully will have spare time soon to experiment with new code.

I noticed the clock seems to have changed on the last chip I programmed, fuses were burned, and it looked good on the bread board.
Once all the resistors/LEDs were soldered on the clock seems to be running faster by about 30%.

#### smeezekitty

#87
##### Aug 23, 2012, 07:39 pm

Ver 16 downloaded, hopefully will have spare time soon to experiment with new code.

I noticed the clock seems to have changed on the last chip I programmed, fuses were burned, and it looked good on the bread board.
Once all the resistors/LEDs were soldered on the clock seems to be running faster by about 30%.

Different power source? Which oscillator?
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!

#### malukens

#88
##### Aug 24, 2012, 09:00 am
John,  I'm back.  A lot Arduino smarter and experienced but still short on both.  I downloaded your latest cores (V16) and was able to get it installed fairly easily.  I didn't see a boards.txt included with the cores so I created a new one using the text you posted in Reply #78 on: August 15, 2012, 12:33:07 PM

Also, your page 1 post now says you "Support 128KHz, 600KHz, 1MHz, 1.2MHz, 4MHz, 4.8MHz, 8MHz, 9.6MHz, 10MHz, 12MHz and 16MHz clock speeds".  Is there a place I can download a more complete boards.txt to get those different configs?

I have successfully uploaded a simple program that initializes three digital outputs and then reads an analog input and uses that analog value to select and then flash one of LEDS on the three digital outputs.

void setup() {
// verify all digital outputs are wired properly
pinMode (0, OUTPUT); pinMode (1, OUTPUT); pinMode (2, OUTPUT);
digitalWrite(0, HIGH); delay(1000) ;  digitalWrite(0,LOW);
digitalWrite(1, HIGH); delay(1000) ;  digitalWrite(1,LOW);
digitalWrite(2, HIGH); delay(1000) ;  digitalWrite(2,LOW);
}

void loop() {
// read the value from the sensor:

// select ledPin based upon analogRead value
int ledPin = 0;
if (potValue > 350) ledPin=1;
if (potValue > 700) ledPin=2;

// turn the selected ledPin on
digitalWrite(ledPin, HIGH); delay(500);
digitalWrite(ledPin, LOW);  delay(500);
}

The program runs as expected on the Uno and a Tiny85 (@8Mhz) but on the Tiny13 with the boards.txt contents referenced above it had two oddities:
First, it runs about 50x slower than the Uno or Tiny85.
Second, the analogRead produces its full range (0 - 1023) in the first 1/4 turn of the POT.  That is, potValue goes from 0 to 1023 with a very short amount of turn.  It was very smooth and gradual on the Uno and took the complete turn to produce values from 0-1023.  Any ideas what would be causing the analogRead to behave so weird?

#### smeezekitty

#89
##### Aug 24, 2012, 07:38 pm
I didn't see a boards.txt included with the cores so I created a new one using the text you posted in Reply #78 on: August 15, 2012, 12:33:07 PM

This is true, currently the core does not ship with a boards.txt.

Quote

Also, your page 1 post now says you "Support 128KHz, 600KHz, 1MHz, 1.2MHz, 4MHz, 4.8MHz, 8MHz, 9.6MHz, 10MHz, 12MHz and 16MHz clock speeds".  Is there a place I can download a more complete boards.txt to get those different configs?

It is not quite that simple.
128KHz is set from the internal watchdog oscillator and is easily selected.
600KHz is the 4.8MHz clock with the /8 fuse set.
1 MHz must be created with an external clock on the '13
1.2MHz is the 9.6MHz clock with the /8 fuse set
4 MHz must be created with an external clock on the '13
4.8MHz is the 4.8MHz internal RC oscillator
8MHz must be created with an external clock on the '13
9.6 MHz is the 9.6MHz internal RC oscillatr
10,12,16 MHz all need to be created with external clocks.
Quote

I have successfully uploaded a simple program that initializes three digital outputs and then reads an analog input and uses that analog value to select and then flash one of LEDS on the three digital outputs.

void setup() {
// verify all digital outputs are wired properly
pinMode (0, OUTPUT); pinMode (1, OUTPUT); pinMode (2, OUTPUT);
digitalWrite(0, HIGH); delay(1000) ;  digitalWrite(0,LOW);
digitalWrite(1, HIGH); delay(1000) ;  digitalWrite(1,LOW);
digitalWrite(2, HIGH); delay(1000) ;  digitalWrite(2,LOW);
}

void loop() {
// read the value from the sensor:

// select ledPin based upon analogRead value
int ledPin = 0;
if (potValue > 350) ledPin=1;
if (potValue > 700) ledPin=2;

// turn the selected ledPin on
digitalWrite(ledPin, HIGH); delay(500);
digitalWrite(ledPin, LOW);  delay(500);
}

The fuse on the section was wrong with the /8 fuse accidentally set
Change
Quote

to
Quote

The program runs as expected on the Uno and a Tiny85 (@8Mhz) but on the Tiny13 with the boards.txt contents referenced above it had two oddities:
Quote
First, it runs about 50x slower than the Uno or Tiny85.

It should be 8x too slow, I am not sure where 50x would come from?
Quote

Second, the analogRead produces its full range (0 - 1023) in the first 1/4 turn of the POT.  That is, potValue goes from 0 to 1023 with a very short amount of turn.  It was very smooth and gradual on the Uno and took the complete turn to produce values from 0-1023.  Any ideas what would be causing the analogRead to behave so weird?

The ADC might be under-clocked from the bad fuse settings. Correct those and try again.
If it persists, I will test later.
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!

Go Up