Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions for changing pinmapping on ATtinyX4 via PlatformIO #882

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions avr/extras/ATtiny_x4.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,37 @@

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.

#### Changing pin mapping via PlatformIO

If you're using [PlatformIO](https://platformio.org/), extra steps must be taken to change your pinmapping.

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.

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.

Or, you can specify the variant manually in your `platformio.ini` file. By default your `platformio.ini` file will look simliar to this:

Check failure on line 74 in avr/extras/ATtiny_x4.md

View workflow job for this annotation

GitHub Actions / spellcheck

simliar ==> similar

```
[env:attiny84]
platform = atmelavr
board = attiny84
framework = arduino
```

Simply add a line specifying the board build variant, and you're good to go!

```
[env:attiny84]
platform = atmelavr
board = attiny84
framework = arduino
board_build.variant = tinyX4_reverse
```

You can test this using the method above. Any code under `#ifdef PINMAPPING_CW` will now compile, and `#ifdef PINMAPPING_CCW` will not.

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\`

### PWM frequency
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.

Expand Down
Loading