What other languages can be used to program Digispark ATTiny85?

Go To Last Post
34 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I believe the Arduino supports C and assembly, but are there other IDEs that support other languages to program a Digispark ATTiny85?

 

I know there is a special board that supports BASIC but the boards are quite expensive at $20-50usd each. PBasic Stamp 2. The BasicX series.

 

I'm a Perl programmer so naturally using Perl would be helpful.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this the board you are talking about? ....

 

http://digistump.com/products/1

 

Looks like it has a USB bootloader which, because it says it is "Arduino compatible" is presumably one of the Arduino ones. So you should be able to use any AVR program authoring system (BASIC, C, C++, Asm, etc) to create .hex files and then separately use a PC tool (avrdude.exe presumably?) to then send the code you have built to the board.

 

As such the world is your oyster. Choose whatever language you like.

 

However do not expect to find Perl for AVR ;-)

 

C++ would probably be the sensible choice these days. (Atmel Studio comes with Asm, C and C++). The Arduino IDE is also C++.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Remember that a microcontroller neither knows nor cares what language you write your source code in, nor what tools you use to translate it.

 

The only thing the microcontroller ever sees is the binary opcodes in Flash.

 

A bootloader may impose some constraints on the program layout in memory, possibly also add a "validity check" - but is otherwise oblivious to the content of the hex file.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, that's the Digispark board I am getting.

 

I might take a look at Basic, that would be nice!

 

  • Where can I find the tools to make .HEX files from different programming languages? Is there a centralized list?
  • Would I google for "AVR program authoring system"?

 

I need a really small board to put in the top of a mason jar along with a 2x CR2032 battery holder.

Last Edited: Tue. May 9, 2017 - 01:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As has already been mentioned, life is easier to start with an Uno, debug your app, then port it to the T85!

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bulrush wrote:
I believe the Arduino supports C and assembly, but are there other IDEs that support other languages to program a Digispark ATTiny85?
The GNAT Programming Studio (GPS) can be used with AVR and Ada on Adafruit's tiny85 board.

https://www.adafruit.com/?q=ATtiny85& (Trinket)

http://arduino.ada-language.com/tag/trinket.html

https://github.com/AdaCore/gps

bulrush wrote:
I'm a Perl programmer so naturally using Perl would be helpful.
Would you consider Python?

pyboard is a bit less expensive than PBASIC Stamp.

MicroPython has been ported to other boards.

https://www.adafruit.com/?q=pyboard&

http://micropython.org/

 


http://www.avrfreaks.net/forum/i-didnt-know-you-could-get-ada-avr

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bulrush wrote:

I might take a look at Basic, that would be nice!

 

I've done a couple of (commercial) projects in Basic using the Bascom compiler.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bulrush wrote:

  • Would I google for "AVR program authoring system"?

 

No. 'Authoring' is the wrong word here. I'd try "AVR xxx compiler" where 'xxx' is the language you are interested in.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

bulrush wrote:

...ATTiny85?

 

Oh, and I wouldn't get too hung up on looking for tools that specifically mention the tiny85. The AVR range of devices are generally compatible with each other, only varying in terms of memory capacity and included peripherals.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hopefully my last question for today: What does AVR stand for? I've been confused on if it's a brand, a class of controller, or something else. Is AVR a generic term covering all the different programmable microcontrollers like Arduino, Digispark, BasicX and others?

 

Thank you for your help!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bulrush wrote:
Is AVR a generic term covering all the different programmable microcontrollers like Arduino, Digispark, BasicX and others?
No; AVR is a registered trademark to Microchip Technology.

Arduino is a registered trademark of Arduino AG.

etc

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bulrush wrote:
What does AVR stand for?
Search Youtube ;-)

 

But first take a look at the first sentence here:

 

https://en.wikipedia.org/wiki/At...

 

Now it might be complete coincidence but might 'A' stand for Alf-Egil and 'V' for Vergard ? (and one might guess that 'R' = RISC) EDIT: just realised it actually says this several paragraphs down anyway!!

 

The bottom line is nobody knows and no one has ever publically explained it.

 

Shame about that Youtube video!!

 

 

Last Edited: Tue. May 9, 2017 - 04:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Clawson,

So AVR is an architecture. Thanks for the link too! It will help me understand what tools are out there.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bulrush wrote:

...microcontrollers like Arduino, Digispark, BasicX and others?

 

Those aren't *really* microcontrollers. Those are more like complete products that use microcontrollers where the microcontroller is partly hidden.

 

I've tried to think of a good analogy and the closest I could come up with is...

 

All those you listed are models of car. What you see is the car and what you 'drive' is the car. Under the hood you have an engine, which is the microcontroller. For many people the hood stays shut and people just use the car. For the tinkerers though, they lift the hood and tweak things. They learn how the engine works and they changes things. Some of those models use the same make of engine, albeit of a different cylinder capacity and configuration, and this is like our different makes and models of microcontrollers but instead of different engine makes and models we have different chip manufacturers and their product lines. So for example we have...

 

Atmel with the AVR line, the SAM line...

Microchip with the PIC18 line, the PIC16 line, the PIC24 line, the PIC32 line...

Texas with the MSP430 line...

 

and many many more.

 

Within those lines you have multiple variants with different memory sizes and peripheral counts.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wouldn't exactly call AVR an "architecture" myself. In the world of micros architecture usually falls into one of two categories: Von Neumann or Harvard. The AVR is a Harvard architecture design.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bulrush wrote:

 

...microcontrollers like Arduino, Digispark, BasicX and others?

 

Brian Fairchild wrote:
Those aren't *really* microcontrollers.

I'd say they are not microcontrollers at all.

 

As you say, they are products that use microcontrollers.

 

Just like your PC is not a microprocessor: sure, a microprocessor is a key component - but the PC is a lot more than just a microprocessor

 

 

clawson wrote:
I wouldn't exactly call AVR an "architecture" myself.

But many people (me included) would!

 

We speak of the "AVR architecture" as distinct from the "8051 architecture" or the "MSP430 architcture" or the "PIC architcture", etc, etc, ...

 

I guess that, on those terms, we would then say that all these architectures can be classified into two main types - Von Neumann or Harvard

 

 

Alternatively, I guess we could say that "Von Neumann or Harvard" classifies computer architectures on the macro scale, while AVR/8051/PIC/ARM classifies implementations on the micro scale... ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can take a look here:  http://www.atmel.com/about/conta...

(Note that some of these are commercial products and cost money!)

I don't think that the tiny85 chip on a Digispark is likely to support RAM-hungry languages like Perl, Python, Smalltalk, etc.

You can get C, C++ (sort of), Forth, Basic (in various different flavors), assorted semi-custom languages (you might want to look at "Bitlash", which is an interpreter for something a bit between BASIC and C), and maybe Ada (sort of.)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

westfw wrote:
C++ (sort of)
Does the "sort of" in that mean "without Standard Template Library" ? There are implementations of the STL for avr-g++ available.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Arduino is not a microcontroller; it uses -at least- two kinds of microcontrollers, AVRs (with/without USB support; with a lot of pins -arduino megas, or ... less pins) and ARMs (Arduino DUE) (btw : I do not know about intel based arduini)

 

it gives about the same connectivity (a extra board -they call it "shield" -, if designed for a UNO, can be plugged into an Arduino Mega ... or a DUE, if it can be powerd with 3v instead of 5....), though their borad layout is very odd (you cannot use, say, veroborads as a shield, as connector spacing is not an integer multiple of 0.1""....)

 

The programming languages are the same : C++ natively, C (and ASM, maybe) for functions -> it is rather easy to understand/port to and from  other microcontrollers

 

Arduino IDE, though somewhat primitive (but I notced there were improvements), comes with a lot of examples and explanations about C++ and HW programming...

 

As Arduino is very popular, it became widely cloned (sometimes with better fuctionalities: better supplies, 2 extra ADC chennels....); Texas designed energia (C++ -and C as extra libraries -, too), which is , to some extend, compatible with Arduino libraries : huge pieces of code written for Arduino can be cut and pasted into energia, with little modifications, and work with MSP430 -a 16 bit microcontroller- , Tivas (ARMs with nice, very fast  ADCs ) and other controllers.

 

Arduino can be extended to attiny 85 (with limitations) or code you wrote for arduino can be used as pseudo code..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does the "sort of" in that mean "without Standard Template Library" ? There are implementations of the STL for avr-g++ available.

It means "without adequate support for things that real C++ programmers seem to think are important."  STL is part of it, and I don't know if "C++ programmers" would be happy with the avr-g++ versions (no exceptions, still?)

See https://softwareengineering.stac... for an example of some who I suspect would not ever be happy with avr-g++

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can use Nim: https://nim-lang.org/ - it can generate small enough binaries.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

federico3 wrote:

You can use Nim: https://nim-lang.org/ - it can generate small enough binaries.

 

If I read the website correctly, "hello world" needs 41k. I can't see that fitting on your average AVR.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Choose  C++ for AVR , that is something like X++ with a centipede. It's not clear where the goal is.blush

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 41k binary is a "hello world" for x86 and with traditional GC.

According to avr-size, a binary to pulse leds on an Digispark attiny85 takes 1382+45 bytes.

Looking at the generated C code, it can be shortened by disabling more language features.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

federico3 wrote:
a binary to pulse leds on an Digispark attiny85 takes 1382+45 bytes.
That's a joke right?!?

C:\SysGCC\avr\bin>type avr.c
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>

int main(void) {
        DDRB = 0xFF;
        while(1) {
                PINB = 0xFF;
                _delay_ms(100);
        }
}
C:\SysGCC\avr\bin>avr-gcc -mmcu=attiny85 -Os avr.c -o avr.elf

C:\SysGCC\avr\bin>avr-size avr.elf
   text    data     bss     dec     hex filename
     72       0       0      72      48 avr.elf

That is a C program for tiny85 to flash all the pins on port B at 5Hz. It takes 72 bytes so how could your "Nim" program take 1300+ more bytes ?!?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

lol

 

Always amusing to see different people's view of what constitutes "low" or "small"

 

eg, Intel talking about "low" power chips taking "only" (sic)  5W !

 

Or the long history of stuff like Java interpreters for small micros (8051, AVR) which take "only" 40K ...

 

laugh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nim generates C code and then runs avr-gcc on it so it's possible to inspect the generated code. By removing fancier animations and implementing the same simple blinking the binary size jumped down to 190+15 bytes.

I can see some structs and error handling functions that can be removed to further reduce the binary size but I see little value in trying to optimize a program that is so simple.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

federico3 wrote:
 I see little value in trying to optimize a program that is so simple.

I guess that's the point:

 

Any program that's going to fit into a small microcontroller is, (almost?) by definition, going to be (quite) simple - so there's little benefit in using stuff like Nim ... ?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

federico3 wrote:
I see little value in trying to optimize a program that is so simple.
You do know that this message board is about programming AVR microcontrollers don't you? They are typically 1 / 2 / 4K devices (perhaps smaller even) so why would anyone using them want to waste the precious flash space with "bloatware" ?

 

What is the "must have" feature in Nim that would make me want to use it over C or C++ (inc. Arduino) or some other language?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
What is the "must have" feature in Nim that would make me want to use it over C or C++ (inc. Arduino) or some other language?

That is the key question!

 

Also, why would one want to go "out on a limb" with a (relatively?) little-known language? What is the compelling benefit?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

federico3 wrote:

Nim generates C code and then runs avr-gcc on it so it's possible to inspect the generated code. By removing fancier animations and implementing the same simple blinking the binary size jumped down to 190+15 bytes.

I can see some structs and error handling functions that can be removed to further reduce the binary size but I see little value in trying to optimize a program that is so simple.

 

I might be missing something here but are you saying that if code size is important, and isn't it always on microcontrollers, I need to manually edit the generated C code?

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

why would one want to go "out on a limb" with a (relatively?) little-known language? What is the compelling benefit?

 

 

Nim has a powerful templating and macro system that could allow writing more high-level code and do as much as possible at compile time instead of runtime, and other features.

Some people like the syntax. Anyhow, the thread is titled "what other languages can be used", I'm not claiming one is better than another for your use-cases.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:

if code size is important, and isn't it always on microcontrollers, I need to manually edit the generated C code?

 

No, there are compiler flags to disable unneeded features, see https://hookrace.net/blog/nim-bi... and http://disconnected.systems/blog...

(Personally, I look at the C code to learn, but the upstream developers accept patches to the compiler.)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Still waiting to hear what is the compelling reason to use Nim (and accept the overhead) ?

 

EDIT

 

Which also prompts the more general question (not limited to (small) microcontrollers) of Nim's purpose - what need does it aim to meet that is not met by other languages?

 

Last Edited: Tue. Aug 22, 2017 - 11:11 AM