Skip to content

Commit

Permalink
Fix x313 clock list. Fix x61 docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SpenceKonde committed Jun 15, 2022
1 parent 521309b commit 7f7cd4e
Show file tree
Hide file tree
Showing 5 changed files with 6,575 additions and 30 deletions.
15 changes: 11 additions & 4 deletions Migration.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
### ATTinyCore Migration Guide
This document describes the considerations for users of the Arduino IDE when migrating to ATTinyCore from other hardware packages that support the ATtiny line or other 8-bit AVR devices, and from the ATtiny84 to the ATtiny841.
This document describes the considerations for users of the Arduino IDE when migrating to ATTinyCore 2.0.0 from other hardware packages that support the ATtiny line or other 8-bit AVR devices, and from the ATtiny84 to the ATtiny841.

### Issues when migrating to ATTinyCore 2.0.x from any other classic AVR core
* Be sure to check the numbering of the analog pins - analogRead() directed at a straight number between 0 and 127 will assume that it is a digital pin, and proceed accordingly. In previous versions, analog channel number would be assumed, which was only the same as the digital pin number in special cases. To refer to analog pins either
* Use their digital pin number: `analogRead(5) (deprecated)` or `analogRead(PIN_PB5)`, etc.
* Use the An constants as shown on the pinout charts: `analogRead(A0)`
* If you must convert an analog channel number to a pin number programmatically, pass it through the ADC_CH() macro
* There is no support for SerialEvent - nor was there ever.

### To ATTinyCore from other cores
Migration to ATTinyCore from other ATtiny hardware packages is typically straightforward - no code modification is typically required, however there are a number of features that require code changes to take full advantage of.
* Two different pin mappings have been used for the ATtiny84 on different cores. Both are supported by ATtinyCore; be sure to select the correct mapping from the Tools -> Pin Mapping menu.
* In order to support the full range of ADC channels, you must use the A# constants, or the ADC channel number when calling analogRead(), not the digital pin number. You may read from differential ADC channels by specifying channel number specified in the datasheets. You may read from the on-board temperature sensor via analogRead(ADC_TEMPERATURE).
Migration to ATTinyCore from other ATtiny hardware packages is typically straightforward - no code modification is typically required except to ensure that analog pin numbers are given correctly, though it may required to reap most of the benefits.
* Many parts have two - or even three - pin mappings available. The recommended one was always chosen to make as much math as possible simplify out.
* When using digitalRead/digitalWrite/pinMode, you must use the digital pin number, the A# constant, or the PIN_xn constants (for example PIN_B3 for PB3).
* ATTinyCore features a builtin universal SPI and Wire library - with other cores, you need to use libraries like TinySPI, TinyWire, USIWire, etc, with any libraries for SPI or I2C devices modified to use these libraries. With ATTinyCore, you may simply include SPI.h or Wire.h, and use unmodified libraries (the ones that would be used on an ATMega device). For the '841/441/828, when using I2C, select from the tools menu whether you want to support master, slave, or both - selecting both will significantly increase flash usage when Wire.h is included.
* ATTinyCore features a builtin Software Serial implementation named Serial on all parts except the '841/441/828/1634/2313/4313 (these parts have proper hardware serial). This uses the AIN1 and AIN0 pins (see the part-specific documentation pages for details); while this is named Serial to make it easy to port code from ATmega-based devices, it is still a software implementation: It is half-duplex (attempting to send and receive at the same time will result in sending and/or receiving gibberish), and sending and receiving is blocking (ie, the processor can do nothing else). Unlike SoftwareSerial, this uses the ACO vector instead of PCINTs, allowing PCINTs to be used by the application or other libraries. SoftwareSerial library may be used instead if desired.
* When using a serial bootloader on any part except the ATtiny828, the EERDY vector may not be used by the application (this is not used by the EEPROM library, and is usually not an issue). Additionally, if the part is reset during the very start of a serial upload, the bootloader will be corrupted - if this happens, the sketch will not work and the bootloader cannot be entered. To resolve this, connect an ISP programmer and "Burn Bootloader" again. Neither of these caveats apply when the serial bootloader is not used.
* When using direct port manipulation on the ATtiny828/841/441/1634, pullups are controlled by the PUEx register (see datasheet for details)


### From ATtiny84 to ATtiny841 (and from ATtiny44 to ATtiny441)
The ATtiny841 is largely compatible with the ATtiny84, only with additional features. There are a few differences to be aware of:
* The ATtiny841 has an additional timer, Timer2, which behaves identically to Timer1 - it is a 16-bit timer with all the same functionality.
Expand Down
17 changes: 11 additions & 6 deletions avr/boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ attinyx4.menu.chip.44=ATtiny44
attinyx4.menu.chip.44.build.mcu=attiny44
attinyx4.menu.chip.44.upload.maximum_size=4096
attinyx4.menu.chip.44.upload.maximum_data_size=256
attinyx4.menu.chip.44=ATtiny44
attinyx4.menu.chip.24=ATtiny24
attinyx4.menu.chip.24.build.mcu=attiny24
attinyx4.menu.chip.24.upload.maximum_size=2048
attinyx4.menu.chip.24.upload.maximum_data_size=128
Expand Down Expand Up @@ -2454,7 +2454,7 @@ attinyx313.build.core=tiny
attinyx313.build.variant=tinyx313
attinyx313.build.export_merged_output=false
attinyx313.bootloader.extended_fuses=0xFE
attinyx313.bootloader.high_fuses=0b{bootloader.rstbit}101{bootloader.eesave_bit}{bootloader.bod_bits}
attinyx313.bootloader.high_fuses=0b1{bootloader.eesave_bit}01{bootloader.bod_bits}1
attinyx313.bootloader.rstbit=1
attinyx313.build.usbpinset=
attinyx313.build.tuneorcal=
Expand Down Expand Up @@ -2497,12 +2497,12 @@ attinyx313.menu.chip.2313.upload.maximum_data_size=128
# Clocking menu options #
################################
attinyx313.menu.clock.internal_8m=8 MHz (internal)
attinyx313.menu.clock.internal_8m.bootloader.low_fuses=0xE2
attinyx313.menu.clock.internal_8m.bootloader.low_fuses=0xE4
attinyx313.menu.clock.internal_8m.build.f_cpu=8000000UL
attinyx313.menu.clock.internal_8m.build.speed=8m
attinyx313.menu.clock.internal_8m.build.clocksource=0
attinyx313.menu.clock.internal_1m=1 MHz (internal)
attinyx313.menu.clock.internal_1m.bootloader.low_fuses=0x62
attinyx313.menu.clock.internal_1m.bootloader.low_fuses=0x64
attinyx313.menu.clock.internal_1m.build.f_cpu=1000000UL
attinyx313.menu.clock.internal_1m.build.speed=1m
attinyx313.menu.clock.internal_1m.build.clocksource=0x10
Expand All @@ -2511,13 +2511,18 @@ attinyx313.menu.clock.internal_4m.bootloader.low_fuses=0x62
attinyx313.menu.clock.internal_4m.build.f_cpu=4000000UL
attinyx313.menu.clock.internal_4m.build.speed=4m
attinyx313.menu.clock.internal_4m.build.clocksource=0x10
attinyx313.menu.clock.internal_4m.bootloader.f_cpu=1000000UL
attinyx313.menu.clock.internal_2m=2 MHz (internal)
attinyx313.menu.clock.internal_2m.bootloader.low_fuses=0x62
attinyx313.menu.clock.internal_2m.bootloader.low_fuses=0x64
attinyx313.menu.clock.internal_2m.build.f_cpu=2000000UL
attinyx313.menu.clock.internal_2m.build.speed=2m
attinyx313.menu.clock.internal_2m.build.clocksource=0x10
attinyx313.menu.clock.internal_2m.bootloader.f_cpu=1000000UL
attinyx313.menu.clock.internal_500k=0.5 MHz (internal)
attinyx313.menu.clock.internal_500k.bootloader.low_fuses=0x62
attinyx313.menu.clock.internal_500k.build.f_cpu=2000000UL
attinyx313.menu.clock.internal_500k.build.speed=500k
attinyx313.menu.clock.internal_500k.build.clocksource=0x10
attinyx313.menu.clock.internal_500k.bootloader.f_cpu=500000UL
attinyx313.menu.clock.crystal_16m=16 MHz (crystal)
attinyx313.menu.clock.crystal_16m.bootloader.low_fuses=0xFF
attinyx313.menu.clock.crystal_16m.build.f_cpu=16000000UL
Expand Down
2 changes: 1 addition & 1 deletion avr/extras/ATtiny_x61.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Though TX defaults to AIN0 (or AIN2), it can be moved to any pin on PORTA using
To disable the RX channel (to use only TX), select "TX only" from the Builtin SoftSerial tools menu. To disable the TX channel, simply don't print anything to it, and set it to the desired pinMode after Serial.begin()

### Servo Support
Although the timers are quite different, and historically there have been issues with the Servo library, we include a builtin Servo library that supports the Tiny x5 series. As always, while a software serial port is receiving or transmitting, the servo signal will glitch (this includes the builtin software serial "Serial). On prior versions, a third party library must be used. The servo library will disable PWM on pin 4, regardless of which pin is used for output, and cannot be used at the same time as Tone. If you have installed a version of Servo through Library Manager, instead include `Servo_ATTinyCore.h` or it will use the incompatible library installed through library manager.
Although the timers are quite different, and historically there have been issues with the Servo library, we include a builtin Servo library that supports the Tiny x61 series. As always, while a software serial port is receiving or transmitting, the servo signal will glitch (this includes the builtin software serial "Serial). On prior versions, a third party library must be used. The servo library will disable PWM on pin 4, regardless of which pin is used for output, and cannot be used at the same time as Tone. If you have installed a version of Servo through Library Manager, instead include `Servo_ATTinyCore.h` or it will use the incompatible library installed through library manager.

## ADC Features
The ATtiny861 has a surprisingly sophisticated ADC, one more advanced than many ATmega parts, with many differential channels, most with selectable gain. As of ATTinyCore 2.0.0, these are available through analogRead! When used to read a pair of analog pins in differential mode, the ADC normally runs in unipolar mode: The voltage on the positive pin must be higher than that on the negative one, but the difference is measured to the full precision of the ADC. It can be put into bipolar mode, where the voltage on the negative side can go below the voltage on the positive side and generate meaningful measurements (it will return a signed value, which costs 1 bit of accuracy for the sign bit). This can be enabled by calling the helper function `setADCBipolarMode(true or false)`. On many AVR devices with a differential ADC, only bipolar mode is available.
Expand Down
Loading

0 comments on commit 7f7cd4e

Please # to comment.