Skip to content

Commit 9e70249

Browse files
authored
Merge pull request #882 from nickyonge/patch-1
Instructions for changing pinmapping on ATtinyX4 via PlatformIO
2 parents 77ae92a + d2c8500 commit 9e70249

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

avr/extras/ATtiny_x4.md

+31
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,37 @@ Example of a "guard" against wrong pin mapping:
6363

6464
All pin mapping options assume that PB2 has the LED (bootloaders will blink that pin, and LED_BUILTIN is defined as PIN_PB2), unless it's a micronucleus configuration with D+ on PB2, in which case it will instead use PB0.
6565

66+
#### Changing pin mapping via PlatformIO
67+
68+
If you're using [PlatformIO](https://platformio.org/), extra steps must be taken to change your pinmapping.
69+
70+
By default, when using "attiny84" as your board on PlatformIO, it uses to the CCW pin mapping. PlatformIO does not have a default menu to simply select your desired pin mapping, and (until when and if a CW mapping for the x4 board is added), you must manually specify the CW board variant in your project's `platformio.ini` file.
71+
72+
In VSCode, you can add this via PlatformIO's inspector. Open your Project, and select Configure. Select your working environment (likely either called "attiny84", "default", or simply unnamed). In the Working Configuration section, in the New Option field, input `board_build.variant`, and add the new field. It will appear under Custom Options at the bottom of the page. Enter `tinyX4_reverse` in this field, and Save.
73+
74+
Or, you can specify the variant manually in your `platformio.ini` file. By default your `platformio.ini` file will look simliar to this:
75+
76+
```
77+
[env:attiny84]
78+
platform = atmelavr
79+
board = attiny84
80+
framework = arduino
81+
```
82+
83+
Simply add a line specifying the board build variant, and you're good to go!
84+
85+
```
86+
[env:attiny84]
87+
platform = atmelavr
88+
board = attiny84
89+
framework = arduino
90+
board_build.variant = tinyX4_reverse
91+
```
92+
93+
You can test this using the method above. Any code under `#ifdef PINMAPPING_CW` will now compile, and `#ifdef PINMAPPING_CCW` will not.
94+
95+
Other variants of ATtiny boards can be found (in Windows, at least - for other OSes, navigate to the relevant install directory) at `C:\Users\USERNAME\.platformio\packages\framework-arduino-avr-attiny\variants\`
96+
6697
### PWM frequency
6798
TC0 is always run in Fast PWM mode: We use TC0 for millis, and phase correct mode can't be used on the millis timer - you need to read the count to get micros, but that doesn't tell you the time in phase correct mode because you don't know if it's upcounting or downcounting in phase correct mode.
6899

0 commit comments

Comments
 (0)