Software > Software

Adding ATtiny85 to BoardDesigner (and beyond)

(1/3) > >>

Gertlex:
(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: ---<?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>
--- End code ---

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

Webbot:
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.

Gertlex:

--- Quote from: Webbot 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.

*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.

--- End quote ---
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.

--- End quote ---
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.

--- End quote ---

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 :)

Webbot:
Taken offline to co-operate on a working solution

Webbot:
Initial version here http://www.societyofrobots.com/robotforum/index.php?topic=7787.0

Navigation

[0] Message Index

[#] Next page

Go to full version