Go Down

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

smeezekitty

#360
Jul 13, 2015, 05:51 am Last Edit: Jul 13, 2015, 07:08 am by smeezekitty
Version 0.21 released

-Edit-
It still isn't 1.6 compliant. I'll try fix that next 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!

swe-dude

Hello i just tried this in arduino 1.0.6 and i get this when i try to compile:
Code: [Select]

C:\Users\stefan\Documents\Arduino\hardware\tiny13\cores\core13_021\events.cpp: In function 'long unsigned int pulseIn(unsigned char, unsigned char, long unsigned int)':
C:\Users\stefan\Documents\Arduino\hardware\tiny13\cores\core13_021\events.cpp:22: error: expected primary-expression before ']' token
C:\Users\stefan\Documents\Arduino\hardware\tiny13\cores\core13_021\events.cpp:22: error: expected `;' before ']' token
C:\Users\stefan\Documents\Arduino\hardware\tiny13\cores\core13_021\events.cpp:27: error: expected `}' at end of input
C:\Users\stefan\Documents\Arduino\hardware\tiny13\cores\core13_021\events.cpp:27: error: expected `}' at end of input


it compiles OK in version 0.20 and 0.19

swe-dude

just found the problem...
this line
Code: [Select]
while(digitalRead(pin) == stat){if((micros() - st) > timeout){return 0;}]
change to
Code: [Select]
while(digitalRead(pin) == stat){if((micros() - st) > timeout){return 0;}}

And its all good.

Any new functions or big changes from last version?

smeezekitty

just found the problem...
this line
Code: [Select]
while(digitalRead(pin) == stat){if((micros() - st) > timeout){return 0;}]
change to
Code: [Select]
while(digitalRead(pin) == stat){if((micros() - st) > timeout){return 0;}}

And its all good.

Any new functions or big changes from last version?
Somehow I uploaded a broken copy of that file. It's weird because
the current version compiled fine here. Anyway, it's fixed now.

Nothing too big. One of the fixes was actually that function (pulseIn)
Besides bug fixes, I worked on some on the ADC code a bit. The next release
should include boards.txt and platform.txt (or whatever it's called) and
hopefully some of the functions will be a few bytes smaller.

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!

Reuti

Hi,

while having a look at the just mentioned events.cpp, I wonder whether all these comparisons are a typo.

Code: [Select]
    to = micros();
    while(digitalRead(pin) == stat){if((micros() - st) > timeout){return 0;}}
    while(digitalRead(pin) != stat){if((micros() - st) > timeout){return 0;}}
    st = micros();
    while(digitalRead(pin) == stat){if((micros() - st) > timeout){return 0;}}
    return micros()-st;


to is initialized but never used, and st used before being initialized. I assume, to stands for "start timeout" and all three comparisons with "timeout" should read:

Code: [Select]
{if((micros() - to) > timeout){return 0;}}

instead to cover an overall timeout.

-- Reuti

smeezekitty

Guys I need help porting over to Arduino 1.6. It's extremely convoluted and I can't even figure out what is required an what is not
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

It was rough but I finally got it done.

Core13 0.22 released!

Features:

Native compatibility with Arduino 1.6.x
Size optimization
pulseIn fixed (again)
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!

cb88

It would be very nice to be able to use attachinterrupt.... as I want to implement a quadrature encoder to pulse and direction sketch. Basically A and B in on change interrupt pins... and direction and increment pulses out on another pin. Alternatively reading out position counters via i2c on the USI port.

766 bytes for my current sketch (although attachinterrupt is missing and I'm just calling the pin read functions from the main loop so it doesn't optimize them out).


Looks like a cool port... I'm glad to see it working in 1.6.5 also (I found 1.6.4 to be rather buggy)!

aleksey_ua

#368
Aug 19, 2015, 11:41 pm Last Edit: Aug 19, 2015, 11:43 pm by aleksey_ua
Arduino IDE 1.6.4
USBasp programmer

On the native "Core 13 0.22" boards.txt I got:
Quote
Error while burning bootloader: missing 'bootloader.tool' configuration parameter
so, I trying to solve this and make own boards.txt 
Please could someone check it.
Code: [Select]
# boards.txt for Arduino 1.6.4

menu.flag=GCC Flags
menu.cpu=Processor
menu.clock=Clock

attiny13.name=Attiny13
attiny13.bootloader.tool=arduino:avrdude
attiny13.upload.tool=arduino:avrdude
attiny13.upload.tool=arduino:arduinoisp
attiny13.upload.using=arduino:usbasp
attiny13.bootloader.unlock_bits=0xff
attiny13.bootloader.lock_bits=0xff
attiny13.build.core=arduino:core13
attiny13.build.board=attiny

attiny13.menu.cpu.attiny13=ATtiny13
attiny13.menu.cpu.attiny13.upload.maximum_size=1024
attiny13.menu.cpu.attiny13.upload.maximum_data_size=64
attiny13.menu.cpu.attiny13.build.mcu=attiny13
attiny13.menu.cpu.attiny13.build.core=core13
# attiny13.menu.cpu.attiny13.build.variant=core13

#################################################
############## clock speeds #####################
#################################################

#### 9.6 MHz
############
attiny13.menu.clock.t13_9M6=9.6MHz (internal clock, Preserve EEPROM, BOD disable)
attiny13.menu.clock.t13_9M6.bootloader.low_fuses=0x3A
attiny13.menu.clock.t13_9M6.bootloader.high_fuses=0xFF
attiny13.menu.clock.t13_9M6.upload.speed=57600L
attiny13.menu.clock.t13_9M6.build.f_cpu=9600000L

#### 9.6 MHz - 2.7V
attiny13.menu.clock.t13_9M6_bod=9.6MHz (internal clock, Preserve EEPROM, BOD - 2.7V)
attiny13.menu.clock.t13_9M6_bod.bootloader.low_fuses=0x32
attiny13.menu.clock.t13_9M6_bod.bootloader.high_fuses=0xFB
attiny13.menu.clock.t13_9M6_bod.upload.speed=57600L
attiny13.menu.clock.t13_9M6_bod.build.f_cpu=9600000L

#### 4.8 MHz - 2.7V
attiny13.menu.clock.t13_4M8_bod=4.8 MHz (int 4.8 MHz clock, Preserve_EEPROM, BOD - 2.7V)
attiny13.menu.clock.t13_4M8_bod.bootloader.low_fuses=0x31
attiny13.menu.clock.t13_4M8_bod.bootloader.high_fuses=0xFB
attiny13.menu.clock.t13_4M8_bod.upload.speed=57600L
attiny13.menu.clock.t13_4M8_bod.build.f_cpu=4800000L

#### 1.2 MHz
attiny13.menu.clock.t13_1M2=1.2 MHz (int 9.6 MHz divided by 8,Preserve_EEPROM, BOD - 2.7V)
attiny13.menu.clock.t13_1M2.bootloader.low_fuses=0x2A
attiny13.menu.clock.t13_1M2.bootloader.high_fuses=0xFB
attiny13.menu.clock.t13_1M2.upload.speed=9600L
attiny13.menu.clock.t13_1M2.build.f_cpu=1200000L

#### 600 kHz
attiny13.menu.clock.t13_0M6=600 kHz (int 4.8 MHz divided by 8, Preserve_EEPROM, BOD disable)
attiny13.menu.clock.t13_0M6.bootloader.low_fuses=0x29
attiny13.menu.clock.t13_0M6.bootloader.high_fuses=0xFF
attiny13.menu.clock.t13_0M6.upload.speed=9600L
attiny13.menu.clock.t13_0M6.build.f_cpu=600000L

## 128 kHz
attiny13.menu.clock.t13_128k=128 KHz (internal watchdog oscillator)
attiny13.menu.clock.t13_128k.bootloader.low_fuses=0x7B
attiny13.menu.clock.t13_128k.bootloader.high_fuses=0xFF
attiny13.menu.clock.t13_128k.upload.speed=250
attiny13.menu.clock.t13_128k.build.f_cpu=128000L

## 16 kHz
attiny13.menu.clock.t13_16k=16 KHz (internal watchdog oscillator, Preserve_EEPROM, BOD disable)
attiny13.menu.clock.t13_16k.bootloader.low_fuses=0x2B
attiny13.menu.clock.t13_16k.bootloader.high_fuses=0xFF
attiny13.menu.clock.t13_16k.upload.speed=250
attiny13.menu.clock.t13_16k.build.f_cpu=16000L



##-----------------------------------
##--------- compiler flags ----------
##-----------------------------------

attiny13.menu.flag.Os=Default
attiny13.menu.flag.Os.compiler.c.extra_flags=
attiny13.menu.flag.Os.compiler.c.elf.extra_flags=
attiny13.menu.flag.Os.compiler.cpp.extra_flags=

attiny13.menu.flag.Os_flto=Default -flto
attiny13.menu.flag.Os_flto.compiler.c.extra_flags=-Wextra -flto
attiny13.menu.flag.Os_flto.compiler.c.elf.extra_flags=-w -flto
attiny13.menu.flag.Os_flto.compiler.cpp.extra_flags=-Wextra -flto

attiny13.menu.flag.O1=-O1
attiny13.menu.flag.O1.compiler.c.extra_flags=-O1
attiny13.menu.flag.O1.compiler.c.elf.extra_flags=-O1
attiny13.menu.flag.O1.compiler.cpp.extra_flags=-O1

attiny13.menu.flag.O1_flto=-O1 -flto
attiny13.menu.flag.O1_flto.compiler.c.extra_flags=-O1 -Wextra -flto
attiny13.menu.flag.O1_flto.compiler.c.elf.extra_flags=-O1 -w -flto
attiny13.menu.flag.O1_flto.compiler.cpp.extra_flags=-O1 -Wextra -flto

attiny13.menu.flag.O3=-O3
attiny13.menu.flag.O3.compiler.c.extra_flags=-O3
attiny13.menu.flag.O3.compiler.c.elf.extra_flags=-O3
attiny13.menu.flag.O3.compiler.cpp.extra_flags=-O3

attiny13.menu.flag.O3_flto=-O3 -flto
attiny13.menu.flag.O3_flto.compiler.c.extra_flags=-O3 -Wextra -flto
attiny13.menu.flag.O3_flto.compiler.c.elf.extra_flags=-O3 -w -flto
attiny13.menu.flag.O3_flto.compiler.cpp.extra_flags=-O3 -Wextra -flto


I have tested this with "Arduino as ISP" and "USBasp programmer" (I would like to use my USBasp programmer in many cases.)

I got an error on the "burn bootloader" stage:
Quote
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x3f != 0xff
avrdude: verification error; content mismatch
but tiny13 was burned and blinking is working now.

P.S. I use a low speed USBasp in the D:\Program Files\Arduino\hardware\arduino\avr\programmers.txt
Code: [Select]

############ USBasp (16 kHz) ##############

usbasp_2.name=USBasp (-B 32: 16 kHz)
usbasp_2.communication=usb
usbasp_2.protocol=usbasp
usbasp_2.program.protocol=usbasp
usbasp_2.program.tool=avrdude
usbasp_2.program.speed=32
usbasp_2.program.extra_params=-B{program.speed}

aleksey_ua


smeezekitty

#370
Aug 20, 2015, 10:40 pm Last Edit: Aug 20, 2015, 10:40 pm by smeezekitty
analogRead(); working only on PB3
I just tested it. analogRead() works on all the ADC pins (except I didn't test the reset pin).
Make sure you use the ADC numbers and not the pin numbers for analogRead

PB2 = ADC1
PB3 = ADC3
PB4 = ADC2
PB5 = ADC0
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!

cb88

I requested ATTiny13A pin change library support here https://github.com/NicoHood/PinChangeInterrupt/issues/4

The code there might be compact enough to make sense on the ATtiny13.

cb88

So for some reason the delay function is not doing what I expect.

So I programmed an ATTiny13A with the blink demo. Changed it to blink on pin 0. The delay I see is acutally 10 seconds + some change.

If I do delay(100) I see 1 second and some change so its off by a factor of 10.

Edit:

I've investigated a bit further. Apparently my fuses were set to 0x6A 0xFF ... which enables dividing the clock by 8. With the fuse bits set to 0x7A 0xFF I now get delay(1000) = 1.31 seconds. delay(770) = 1 second.

orlv

Hi! I fixed all of the firmware uploading warnings, and changed menu.

https://github.com/orlv/at13

Changes in boards.txt and platforms.txt

hansibull

Isn't it possible to minimize the footprint of this core even more? a "blank" sketch (empty setup() and loop() ) takes up 172 bytes. Thats 17% of the memory without doing anything!

Wouldn't it be possible to instead have to start things like millis and micros manually, using #define? This would make this core a little more "manual", but the footprint would be much smaller.

(This core should also be hosted on Github rather than SourceForge, for obvious reasons)
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

Go Up