Digispark Attiny microcontrollers implementation

dav

Introduction

The Digispark is an Attiny85 based microcontroller, and much less well known than Arduino. But considering their price, it seems interesting to learn how to program them.

Digispark microcontrollers features:

Attiny85 based microcontroller (Digispark):

  • Support Arduino IDE 1.0+ (OSX/Win/Linux)
  • Power via USB or External Source – 5v or 12v
  • On-board 500ma 5V Regulator
  • Built-in USB
  • 6 I/O Pins (2 are used for USB only if your program actively communicates over USB, otherwise you can use all 6 even if you are programming via USB)
  • 8k Flash Memory (about 6k after bootloader)
  • 512B EEPROM, 512-Byte SRAM
  • I2C and SPI (vis USI)
  • PWM on 3 pins (more possible with Software PWM)
  • ADC on 4 pins
  • Power LED and Test/Status LEDLF, HF full band.

Attiny167 based microcontroller (Digispark pro):

  • Compatible with Arduino IDE 1.5 (OSX/Win/Linux)
  • USB programming, USB device emulation, USB-CDC virtual serial port emulation
  • 16 Mhz AVR MCU – using a true 16Mhz precision crystal
  • 16KB Flash Memory (14.5K+ after bootloader)
  • 512B EEPROM, 512-Byte SRAM
  • Serial over USB debugging and communication!
  • 14 i/o Pins (2 shared with USB)
  • I2C, true SPI, UART, LIN, and USI
  • ADC on 10 pins
  • 3 PWM Channels (which can be assigned to a selection of pins)
  • Power via USB, or External Source – 5v or 6-16v (automatic selection)
  • On-board button that can be used as a reset, program, or user button – or can be disabled to use that pin as general i/o – without changing the bootloader
  • On-board 500ma 5V regulator
  • Power LED and Test/Status LED (on Pin 1)
    Breadboard compatible pin out/spacing (the three side header pins are only for legacy shield support).

1 – Attiny85 based microcontroller :  Digispark

digi_ebay
You will find the digispark on ebay

1.1 Bootloader programming

The bootloader is the little program that runs when you turn the digispark on. Its main function is to wait for the Digispark software on your computer to send it a new program for the Digispark, which it then writes to the memory on the Digispark. This is important, because normally you need a special device to program the Digispark. The bootloader is what enables you to program the Digispark using just the USB plug.

When you buy it, there may be no bootloader indide it. How to program it ?

usbasp
Use an USBASP
wiringV2
USBASP wiring
wiringV1
The other version, same schematics
usbasp_pinoutvisual2
Pinout details
dav
You can build an interface between the UASBASP and the digispark
pcb
Componant side

 

Ce diaporama nécessite JavaScript.


1.2 Download https://github.com/f4goh/micronucleus/archive/master.zip

This is a fork from https://github.com/micronucleus/micronucleus with add-on programs (F4goh_files)

– Install  USBasp-win-driver-x86-x64-ia64-v1.2.4 drivers and Avrdude (setup-AVRDUDESS-2.6.exe)

– Plug USBASP (check drivers on Windows device managers )

usbaspdrivers.png
Yes, USBasp is ok

 

  • Select USBasp
  • Port USB
  • Load t85_default.hex
  • Set fuses lock bits to L : 0xE1 , H : 0XDD
  • Click Program!
prog avrdude
Program t85_default.hex
trouble isp
If you have an error like this, go to troubleshooting at the end of this page
bits_selector
If you want to use reset pin as an IO, clear RSTDISBL, but you can’t use USBasp after. Only bootloader. To reverse it, you need to unlock it with an high voltage. (See useful links)

1.3 Digispark IO and schematics

digispark

digispark_attiny85_pinout_by_mortenaaserud-dc7h4n3

schematics

attiny85

687474703a2f2f6472617a7a792e636f6d2f652f696d672f50696e6f75745438352e706e67

PIN Function Port Arduino Peripherals
1 (PCINT5/RESET/ADC0/dW) PB5 PB5 5/A0
2 (PCINT3/XTAL1/CLKI/OC1B/ADC3) PB3 PB3 3/A3 USB M
3 (PCINT4/XTAL2/CLKO/OC1B/ADC2) PB4 PB4 4/A2 USB P
4 GND
5 PB0 (MOSI/DI/SDA/AIN0/OC0A/OC1A/AREF/PCINT0) PB0 0 SDA
6 PB1 (MISO/DO/AIN1/OC0B/OC1A/PCINT1) PB1 1
7 PB2 (SCK/USCK/SCL/ADC1/T0/INT0/PCINT2) PB2 2/A1 SCL
8 VCC

1.4 Digispark pro IO and schematics

DigisparkProDiagram2

schematicsPro

attiny167
ATtiny167

2 – Arduino IDE configuration

2.1 Follow this setup :

http://digistump.com/wiki/digispark/tutorials/connecting

Install micronucleous Drivers, if this hasn’t been done.

path to drivers

preferences
perefences.txt show where digispark drivers is.

 

 

digi all drivers

2.2 blink test

start 1

start 2
Check Digispark default, program and plug the device as says the prompt message
start 3
yes , led binking

3 – Troubleshooting

Digispark alternative programming with an Arduino UNO :

F8O9G9ZIDWXMRXV.LARGE
Digispark wiring. I didn’t plug the capacitor.
arduino isp uno
Upload Arduino ISP program in the UNO
arduino isp
Program digispark

I can’t use USBasp :

May be it is a fake programmer, so you must reload the firmware.

usbasp_and_arduino wire
Wires between UNO and USBasp
IMGP0586a-300x230
put a wire to enable programming mode
arduino isp for usb asp
Program USBasp with 20130212_mega8_usbisp.hex according with fuses bytes 0xEF and 0xC9

Remove wire programming on USBasp. It should work.

Useful links :

https://www.sciencetronics.com/greenphotons/?p=938

http://irq5.io/2017/07/25/making-usbasp-chinese-clones-usable/

https://www.fischl.de/usbasp/

https://www.instructables.com/id/How-to-unlock-Digispark-ATtiny85-and-convert-it-to/

https://www.elektor.fr/50-mini-projets-instructifs-a-microcontroleur

https://github.com/digistump

Keyboards layouts :

https://github.com/ernesto-xload/DigisparkKeyboard

 


4 – Conclusion

I hope this tutorial will make it easier for you to use digispark cards. I tried to gather useful information to facilitate programming. Screenshoots should help you a lot. I will soon be proposing Hamradio applications using digispark modules.


Under linux :

https://digistump.com/wiki/digispark/tutorials/linuxtroubleshooting

Commands list on  console:

sudo apt-get install libusb-dev

git clone https://github.com/micronucleus/micronucleus

cd micronucleus

cd commandline

make

sudo cp 49-micronucleus.rules /etc/udev/rudes.d

Replace micronucleus exec file in .arduino15/pakages/digisump/tools/micronucleus/2.0a4/

 

 

 

 

 

 

 

 

 

 

Publicités
Digispark Attiny microcontrollers implementation

2 réflexions sur “Digispark Attiny microcontrollers implementation

Répondre

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Google

Vous commentez à l'aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s