Go Down

Topic: MicroCore - An optimized and efficient Arduino core for ATtiny13 (Read 11134 times) previous topic - next topic

swe-dude

Hello again
One problem with
Code: [Select]
// Wrapper to deal with _delay_ms(), which is an inline function
void delay(uint16_t ms)
{
  while(--ms)
    _delay_ms(1);
}


delay(1); will have no delay at all, and all bigger delays will be 1 ms too fast.

I did a crude fix to make it work for me,  but you might have a better idea abut how to solve it.
Code: [Select]
void delay(uint16_t ms)
{
ms++;
  while(--ms)
    _delay_ms(1);
}

hansibull

I don't have my Attiny here at the moment, but does this function work better?

Code: [Select]

void delay(uint16_t ms)
{
  do
  {
     _delay_ms(1);
  } 
  while(--ms);
}
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

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

swe-dude


hansibull

The "new" delay function is actually two bytes smaller than the old one. Seems like the compiler like the do while structure better ;) if I'm writing ms-- instead of --ms without LTO enabled, the code actually gets 4 bytes larger!
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

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

Chris72622

Hi,

i burned the bootloader to an ATtiny 13A, now i want to upload a sketch.

I used USB TinyISP for burning the bootloader. Can i also use the USB Tiny ISP for uploading the sketch?

When i want to upload there came up this message:

"Build-Optionen wurden verändert, alles wird neu gebaut
sorry - this program has been built without plugin support
Fehler beim Kompilieren." (german)

Greetz Chris
Bilnk wtiohut daley.

Chris72622

Hi,

i burned the bootloader to an ATtiny 13A, now i want to upload a sketch.

I used USB TinyISP for burning the bootloader. Can i also use the USB Tiny ISP for uploading the sketch.

When i want to upload there came up this message:

"Build options have been changed, everything is being rebuilt
sorry - this program has been built without plugin support
Error when compiling."

Greetz Chris
Bilnk wtiohut daley.

DrAzzy

ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

hansibull

Quote
Can i also use the USB Tiny ISP for uploading the sketch.
Yes you can. Simply hit the upload button
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

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

Remco_FYM

Hi Hansibull,

Reading this thread this post may be off topic, but I'm out of ideas , so I give it a try here.

I found your 'MIcroCore' a while ago and had to wait some time for my ATTiny13a's to arrive.
It seems your 'MicoCore' is relatively new and not many pages are referring to it.

To put it short: I'm unable to communicate with the ATTiny13a.

I read loads of pages on how to program an ATTiny13(a), also including your 'cook book
recipe', but as I just stated: unfortunately no go.

I try to describe my setup/situation as accurate as possible, hoping you may find a flaw or error
I made.

1. I followed the instructions on how to install your core <-- no problem

2. ATTiny13a was connected to an Arduino NANO board per your instructions <-- 4x checked
(visually, also with multimeter etc etc)

3. Used default settings (9.6 MHz, BOD = 2.7V etc )

4. You write: "Select what kind of programmer you're using under the Programmers menu."

I think here is where my issue starts as I can't burn the bootloader (fuse settings) into
the ATTiny13a.

I tried almost all 'programmers' and stayed with the 'Arduino as ISP' programmer.

Following the instructions on several well documented web sites on how to use an Arduino
as ISP, still no result, i.e. either programming the ATTiny or burning the fuses/bootloader.

I digged further into 'Arduino as ISP' and investigated pin5 of the ISP header.
All websites I read connect pin5 of the ISP header to pin1 of the ATTiny13(a), aka RESET.

I found out that in the 'example sketch' Arduino as ISP , Arduino pin10 (PB2) is used
to reset the external microcontroller. With a multimeter I determined that on my Nano
board, the ISP header pin5 is connected to the ATMega328 reset pin (RST pins on Nano board).

OK.. might this be my issue? So, I disconnected pin5 from the ISP to the RST pins by scratching
the corresponding track with a small screw driver and connect pin5 ISP to pin10 (PB2) of the
ATMega328.

Still no result.

I'm out of ideas . . .












Remco_FYM

Perhaps for your convenience (or others), this is the output in the status window:
Code: [Select]

/home/user/arduino-1.8.1/hardware/tools/avr/bin/avrdude -C/home/user/.arduino15/packages/MicroCore/hardware/avr/1.0.1/avrdude.conf -v -pattiny13 -cstk500v1 -B32 -P/dev/ttyUSB0 -b19200 -e -Ulock:w:0x3f:m -Uhfuse:w:0xfb:m -Ulfuse:w:0x3A:m

avrdude: Version 6.3, compiled on Dec 16 2016 at 12:32:01
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/user/.arduino15/packages/MicroCore/hardware/avr/1.0.1/avrdude.conf"
         User configuration file is "/home/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         Setting bit clk period        : 32.0
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x15
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x15
         AVR Part                      : ATtiny13
         Chip Erase delay              : 4000 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no         64    4      0  4000  4000 0xff 0xff
           flash         65     6    32    0 yes      1024   32     32  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          2    0      0     0     0 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
         Hardware Version: 4238718
         Firmware Version: 0.0
         Topcard         : STK502
         Vtarget         : 1.8 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10

avrdude done.  Thank you.

Error while burning bootloader.

pert

All websites I read connect pin5 of the ISP header to pin1 of the ATTiny13(a), aka RESET.
That's definitely wrong. You are correct to connect pin 10 to the reset pin of the target board, though I wouldn't have cut the trace. This is actually a valuable lesson that there is a ton of bad information out there regarding Arduino so you should always be critical. This website is also certainly not infallible, but you can see they do show pin 10 of the programmer board connected to reset on the target board here:
https://www.arduino.cc/en/Tutorial/ArduinoISP

Remco_FYM

OK, I have _some_ success and managed to program a 'fresh'/new ATTiny13a
according to the procedure above (with ISP pin5 connected to Nano pin10 (PB2)
and ... with a fresh install of the Arduino IDE on another (linux) machine, together
with the MicroCore library as mentioned in this topic title.

Thus:

1. loaded the same Nano with the ArduinoISP sketch.

2. selected ATTiny13 from the board menu

3. selected Arduino as ISP

4. hit Tools --> Burn Bootloader

The status reply was as follows:

Code: [Select]

avrdude: Version 6.3, compiled on Dec 16 2016 at 07:33:21
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/user/.arduino15/packages/MicroCore/hardware/avr/1.0.1/avrdude.conf"
         User configuration file is "/home/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         Setting bit clk period        : 32.0
         AVR Part                      : ATtiny13
         Chip Erase delay              : 4000 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no         64    4      0  4000  4000 0xff 0xff
           flash         65     6    32    0 yes      1024   32     32  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          2    0      0     0     0 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9007 (probably t13)
avrdude: erasing chip
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xfb"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xfb:
avrdude: load data hfuse data from input file 0xfb:
avrdude: input file 0xfb contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0x3A"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0x3A:
avrdude: load data lfuse data from input file 0x3A:
avrdude: input file 0x3A contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done.  Thank you.

avrdude: ser_open(): can't open device "unknown": No such file or directory
Error while burning bootloader.


5. I ignored the last 'ser_open()' issue.

6. ATTiny13(a) sketch was loaded

7. Selected Tools --> Board --> ATTiny13  (with default settings i.e. 9.6 MHz clock , 2.7V BOD etc)

8. (with Arduino as ISP still selected) Sketch --> Upload Using Programmer

9. Bingo!


The ATTiny13a is used to program an ADF4351 PLL and everything works fine.

However ... when I changed the PLL settings/registers in the code (to program a different
frequency in the PLL) ... and therefore needed to  re-upload the modified sketch I get errors resulting in not uploading the sketch.

My conclusions:

The hardware setup to program a (fresh?) ATTiny13a seems ok, as well as the applied
procedure for only one time.

Anybody any hints?






Remco_FYM

I think I [solved] my issue as I can program my ATTiny13a's, despite the
avrdude: ser_open() error. But what the heck ; -)

I connected a scope to all signals (SCK, MOSI, MISO and /RESET) and found out
the /RESET was mangled.

The apparent remedy was reducing the pull up resistor from 10k to around 4k,
by placing a 6k8 resistor in parallel.

So, my 2 cts for testing the MicroCore ATTiny13a . . .

mcnobby

Hi,
I have planned to use the ATTINY13a for a very fast processing job, mostly written in assembler, ,but I have hit a snag at the first hurdle..

My program (below) runs fine for the first dozen or so HI-LO's, then there is a mahoosive gap in output until the next set of HI-LOs comes round (its like it has hit a timer overflow because I am looping in assembler, which is what I ultimately intend to do). I will be using TIMER0 for some interrupt work a bit later

I have read about the disabling of things in core_settings.h, which I have done, but yet it still does the above

My code
Code: [Select]
#define OUT_PORT   (PORTB)
#define OUT_PIN 2

#include <avr/io.h>
//#include <util/delay.h>

int main(void)

  DDRB |= 0b00011111;     
  while(1) {
  asm (
    "loop_%=:\n"
      "sbi %[out_port],%[out_pin]\n"  // SET PIN HIGH
      "cbi %[out_port],%[out_pin]\n"  // SET PIN LOW
      "rjmp loop_%=\n"

      ::
      [out_port] "I" (_SFR_IO_ADDR(OUT_PORT)),
      [out_pin] "I" (OUT_PIN)
      : 
    );
  }
  return 0;
}
http://www.youtube.com/user/Recovered
http://www.smartshow.lighting

mcnobby

Sorry, I found it
All I needed to do was disable the BOD in the selection when burning bootloader
http://www.youtube.com/user/Recovered
http://www.smartshow.lighting

Go Up