go away spammer

Author Topic: Adding ATtiny85 to BoardDesigner (and beyond)  (Read 3941 times)

0 Members and 1 Guest are viewing this topic.

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Adding ATtiny85 to BoardDesigner (and beyond)
« on: September 07, 2013, 09:19:41 AM »
(These are probably questions solely for Webbot)

I figured I'd try to use Webbotlib and its tools to play with the handful of ATtiny85 MCUs that I got for side projects.

The initial step is to add this MCU to BoardDesigner's options.  I dove into the documentation for the ATtiny85 and also for the Atmega32 as a point of reference.  It took me a while, but I have a (mostly) complete .mcu file.  The catch is that the ATtiny85 does not have a UART, so my UARTS section in the .mcu file is empty.  Board Designer complains about this.  Removing the UARTS section altogether doesn't work either, unsurprisingly.

I imagine I might be able to put a fake placeholder UART in there (though I'm skeptical I'd be able to compile any generated code), but should Board Designer perhaps be modified to accommodate MCUs with no UARTs?

One of the next steps once I get past this will be to create a libWebbot-attiny85.a library file... I'll figure that out, but anything I should know that's going to give me particular trouble?

I've included my .mcu file contents below.  The part I'm least certain about is Timer1's C compare channel; it's different from A and B, and from anything that the Atmega32 .mcu file defines. (I've not looked at other .mcu files yet)

Code: [Select]
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE processor SYSTEM "http://webbot.org.uk/webbotlib/dtds/processor_V_1_0.dtd">
<processor eprom="512" flash="8192" processor="ATtiny85" ram="512"><VERSION major="1" minor="0"/><PACKAGES>
<PACKAGE id="PDIP_8" pins="8" type="PDIP">
<PIN id="1" iopin="B5"><ALT id="PCINT5"/><ALT id="'RESET"/><ALT id="ADC0"/><ALT id="dW"/></PIN>
<PIN id="2" iopin="B3"><ALT id="PCINT3"/><ALT id="XTAL1"/><ALT id="CLKI"/><ALT id="'OC1B"/><ALT id="ADC3"/></PIN>
<PIN id="3" iopin="B4"><ALT id="PCINT4"/><ALT id="XTAL2"/><ALT id="CLKO"/><ALT id="OC1B"/><ALT id="ADC2"/></PIN>
<PIN id="4"><ALT id="GND"/></PIN>
<PIN id="5" iopin="B1"><ALT id="MOSI"/><ALT id="DI"/><ALT id="SDA"/><ALT id="AIN0"/><ALT id="OC0A"/><ALT id="'OC1A"/><ALT id="AREF"/><ALT id="PCINT0"/></PIN>
<PIN id="6" iopin="B0"><ALT id="MISO"/><ALT id="DO"/><ALT id="AIN1"/><ALT id="OC0B"/><ALT id="OC1A"/><ALT id="PCINT1"/></PIN>
<PIN id="7" iopin="B6"><ALT id="SCK"/><ALT id="USCK"/><ALT id="SCL"/><ALT id="ADC1"/><ALT id="T0"/><ALT id="INT0"/><ALT id="PCINT2"/></PIN>
<PIN id="8"><ALT id="VCC"/></PIN>
</PACKAGE>
</PACKAGES>
<PORTS>
<PORT ddr_reg="DDRB" id="PORTB" pin_reg="PINB" port_reg="PORTB">
<IOPIN id="B0" pin="5"/>
<IOPIN id="B1" pin="6"/>
<IOPIN id="B2" pin="7"/>
<IOPIN id="B3" pin="2"/>
<IOPIN id="B4" pin="3"/>
<IOPIN id="B5" pin="1"/>
</PORT>
</PORTS>
<UARTS>
</UARTS>
<TIMERS>
<TIMER bits="8" counter="TCNT0" id="0" prescaler="TCCR0B" wgm_bits="3">
<PORT_MASK mask="TOIE0" name="overflow_int_enable" port="TIMSK"/>
<PORT_MASK mask="TOV0" name="overflow_int_request" port="TIFR"/>
<WGM>
<PORT_MASK mask="WGM00" port="TCCR0A"/>
<PORT_MASK mask="WGM01" port="TCCR0A"/>
<PORT_MASK mask="WGM02" port="TCCR0B"/>
</WGM>
<COMPARE channel="A" pwm="OC0A" threshold="OCR0A">
<PORT_MASK mask="OCIE0A" name="compare_int_enable" port="TIMSK"/>
<PORT_MASK mask="OCF0A" name="compare_int_request" port="TIFR"/>
<PORT_MASK mask="COM0A0" name="com" port="TCCR0A"/>
</COMPARE>
<COMPARE channel="B" pwm="OC0B" threshold="OCR0B">
<PORT_MASK mask="OCIE0B" name="compare_int_enable" port="TIMSK"/>
<PORT_MASK mask="OCF0B" name="compare_int_request" port="TIFR"/>
<PORT_MASK mask="COM0B0" name="com" port="TCCR0A"/>
</COMPARE>
</TIMER>
<TIMER bits="8" counter="TCNT1" id="1" prescaler="TCCR1" wgm_bits="0">
<PORT_MASK mask="TOIE1" name="overflow_int_enable" port="TIMSK"/>
<PORT_MASK mask="TOV1" name="overflow_int_request" port="TIFR"/>
<COMPARE channel="A" pwm="OC1A" threshold="OCR1A">
<PORT_MASK mask="OCIE1A" name="compare_int_enable" port="TIMSK"/>
<PORT_MASK mask="OCF1A" name="compare_int_request" port="TIFR"/>
<PORT_MASK mask="COM1A0" name="com" port="TCCR1"/>
</COMPARE>
<COMPARE channel="B" pwm="OC1B" threshold="OCR1B">
<PORT_MASK mask="OCIE1B" name="compare_int_enable" port="TIMSK"/>
<PORT_MASK mask="OCF1B" name="compare_int_request" port="TIFR"/>
<PORT_MASK mask="COM1B_" name="com" port="TCCR__"/>
</COMPARE>
<!-- <COMPARE channel="C" pwm="OC1C" threshold="OCR1C">? there is no OC1C pin, but there is an OCR1C register ?
<PORT_MASK mask="OCIE0B" name="compare_int_enable" port="TIMSK"/>?? not for C
<PORT_MASK mask="OCF0B" name="compare_int_request" port="TIFR"/>?? not for C
<PORT_MASK mask="COM0B0" name="com" port="TCCR__A"/>
</COMPARE> -->
</TIMER>
</TIMERS>
<INTS>
<INT number="0">
<PORT_MASK mask="INT0" name="int_enable" port="GIMSK"/>
<PORT_MASK mask="INTF0" name="int_pending" port="GIFR"/>
<SenseCtrl>
<PORT_MASK mask="ISC00" name="sense" port="MCUCR"/>
<PORT_MASK mask="ISC01" name="sense" port="MCUCR"/>
</SenseCtrl></INT>
</INTS>
</processor>

The ATtiny 25 and 45 would of course be supported just by changing the details in the <processor> element.
I

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #1 on: September 14, 2013, 08:08:32 AM »
Quick answer is that WebbotLib has never supported ATtinys. With only 8k flash the ATtiny85 may struggle to fit your runtime unless its very small - since WebbotLib does add some code overhead. For the same reason I've always maintained that the ATMega8 is also borderline.

Its not recommended that you hand write your own mcu files!!! I have my own app that generates them from buggy files provided by ATmel. This app also makes sure that the mcu obeys certain assumptions made within WebbotLib itself and if you code the file by hand these checks are bypassed. For example: WebbotLib assumes the timer prescalers are 3 bit but when I run the ATtiny85 thru my app then it reports it timer1 as 4 bit (which the datasheet confirms). So even if you get it to work in the Designers and compile then you will get strange results.

If you try to compile WebbotLib for ATtiny85 you will also find other files that fall over. For example: the I2C code needs #defines to say which pins are used; and there are others.

Before I spend too much time on this then you may like to compile your code as if you were using an ATMega8 - just to see if the code would actually fit on an 8k device. If its way too big then I'd be wasting my time on changing the Designers and WebbotLib and WebbotLib Studio.

Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #2 on: September 14, 2013, 01:41:46 PM »
Quick answer is that WebbotLib has never supported ATtinys. With only 8k flash the ATtiny85 may struggle to fit your runtime unless its very small - since WebbotLib does add some code overhead. For the same reason I've always maintained that the ATMega8 is also borderline.

*snip*

Before I spend too much time on this then you may like to compile your code as if you were using an ATMega8 - just to see if the code would actually fit on an 8k device. If its way too big then I'd be wasting my time on changing the Designers and WebbotLib and WebbotLib Studio.
I don't currently have specific code set to go (in part because I typically start from Webbotlib's pregenerated stuff, of course ;) ), but an empty project compiles to 13% usage with the Atmega8, so I figure the simple stuff I'm considering would fit fine.

Quote
Its not recommended that you hand write your own mcu files!!! I have my own app that generates them from buggy files provided by ATmel. This app also makes sure that the mcu obeys certain assumptions made within WebbotLib itself and if you code the file by hand these checks are bypassed. For example: WebbotLib assumes the timer prescalers are 3 bit but when I run the ATtiny85 thru my app then it reports it timer1 as 4 bit (which the datasheet confirms). So even if you get it to work in the Designers and compile then you will get strange results.
It was still a good way to force myself to dig into the MCU docs more ;)  I definitely noticed differences between the Attiny and Atmega lines...

Quote
If you try to compile WebbotLib for ATtiny85 you will also find other files that fall over. For example: the I2C code needs #defines to say which pins are used; and there are others.

Yeah... maybe I'll finally install the Arduino environ instead (so I can refer to various existing, functioning code), before moving on to a more from-scratch approach. Bleh :)
I

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #3 on: September 15, 2013, 01:44:48 PM »
Taken offline to co-operate on a working solution
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #5 on: October 13, 2013, 08:51:14 PM »
Hey Webbot,

I've played with the updated Webbotlib this weekend and last.  Currently I have a blinking LED setup, whoo!  Much learning along the way; fuses, avrdude, external oscillator, board designer, etc.  I am using the Tiny AVR Programmer from Sparkfun.

Currently I'm using a 16 MHz crystal, and it looks like software thinks I'm running at 1 MHz.  Haven't looked beyond calculating that ratio (I calculated very crudely, 15 as my ratio; was too lazy to hook up the Saleae Logic).

Hopefully I'll play with more stuff in the evenings this week.
I

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #6 on: October 14, 2013, 07:16:26 PM »
Chances are that in Board Designer you have left the CPU speed to the default of 1Mhz - so just edit it and save. Then regen your project based on that board.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #7 on: October 14, 2013, 07:38:29 PM »
Chances are that in Board Designer you have left the CPU speed to the default of 1Mhz - so just edit it and save. Then regen your project based on that board.

Hah, there it is. Project Designer has me very used to ignoring that part of the screen :)
I

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #8 on: December 04, 2013, 07:23:31 PM »
So to update, I did in fact do something back in October; specifically, a tiny infinity mirror.  The biggest hangup was my own fault; decrementing an unsigned int so that it looped around and my LEDs didn't behave.

I used a WS2812 LED string. And added someone else's library for the purpose, along with Webbotlib.

I used a small convex bike mirror, so it was not a true infinity mirror.  To do tinting, I used two layers of antistatic bagging from a motherboard's packing materials... :D  The glass and bezel came from a small clock (which conveniently fell to its death a few months prior).  The pumpkin required my going outside to acquire...

Oh, and a cruddy video from before I found the unsigned int overflow bug; I had 12 LEDs before I acquired an extra one (these were all free from a generous coworker), and candles behind the LEDs for awesome effect!: Infinity Mirror Pumpkin

Images below: final board-less 8-pin socket with soldered on caps, crystal and pins; daylight shot; First test with a large mirror; pumpkin with companions at a pumpkin carving party.
« Last Edit: December 04, 2013, 09:35:11 PM by Gertlex »
I

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #9 on: December 04, 2013, 10:31:58 PM »
You know what impressed me the most?
That "backpack" use of a DIP-8 socket. Genius!
:-)

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #10 on: December 05, 2013, 03:04:28 PM »
Glad you got it all going !

Quote
I used a WS2812 LED string. And added someone else's library for the purpose, along with Webbotlib.
Cool - just shows that folk don't need 'me' to add every device imaginable.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Adding ATtiny85 to BoardDesigner (and beyond)
« Reply #11 on: December 29, 2013, 04:44:55 PM »
Got around to uploading the cleaned up and slightly refined code.  (oh right, forgot to remove a bunch of commented stuff; oh well!)

https://github.com/erelson/ATTiny85_InfinityMirror
I

 


Get Your Ad Here