Hi everybody,
I’m using VSCode/PlatformIO to develop for an ATtiny84A. I need 6 PWM channels to control the brightness of 6 LEDs. I can get the 4 hardware PWM channels to work right away. I’m trying to use SoftPWM library by Brett Hagman to get two more of the pins to output a PWM signal. I used the Library Manager to search the Registry for SoftPWM library and clicked on “Add to Project”. This is my current platformio.ini:
[env:attiny84]
platform = atmelavr
board = attiny84
framework = arduino
board_build.f_cpu = 8000000L
upload_protocol = stk500
board_fuses.efuse = 0xFF
board_fuses.hfuse = 0xDF
board_fuses.lfuse = 0xE2
upload_flags =
-P$UPLOAD_PORT
-b$UPLOAD_SPEED
upload_speed = 115200
upload_port = COM7
lib_deps = bhagman/SoftPWM@^1.0.1
However, when I add
#include <SoftPWM.h>
to my main.cpp and try to compile the project, I get the following output:
In file included from .pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:42:0:
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp: In function 'void TIMER2_COMPA_vect()':
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:36:36: warning: 'TIMER2_COMPA_vect' appears to be a misspelled 'signal' handler, missing '__vector' prefix [-Wmisspelled-isr]
#define SOFTPWM_TIMER_INTERRUPT TIMER2_COMPA_vect
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:85:5: note: in expansion of macro 'SOFTPWM_TIMER_INTERRUPT'
ISR(SOFTPWM_TIMER_INTERRUPT)
^~~~~~~~Compiling .pio\build\attiny84\FrameworkArduino\new.cpp.o
~~~~~~~~~~~~~~~
In file included from .pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:44:0:
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp: In function 'void SoftPWMBegin(uint8_t)':
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:39:3: error: 'TIFR2' was not declared in this scope
TIFR2 = (1 << TOV2); /* clear interrupt flag */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:39:3: note: suggested alternative: 'TIFR0'
TIFR2 = (1 << TOV2); /* clear interrupt flag */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~Compiling .pio\build\attiny84\FrameworkArduino\wiring.c.o
~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:39:17: error: 'TOV2' was not declared in this scope
TIFR2 = (1 << TOV2); /* clear interrupt flag */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~Compiling .pio\build\attiny84\FrameworkArduino\wiring_analog.c.o
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:39:17: note: suggested alternative: 'TOV0'
TIFR2 = (1 << TOV2); /* clear interrupt flag */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:40:3: error: 'TCCR2B' was not declared in this scope
TCCR2B = (1 << CS21); /* start timer (ck/8 prescalar) */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:40:3: note: suggested alternative: 'TCCR0B'
TCCR2B = (1 << CS21); /* start timer (ck/8 prescalar) */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:40:18: error: 'CS21' was not declared in this scope
TCCR2B = (1 << CS21); /* start timer (ck/8 prescalar) */ \
^
Compiling .pio\build\attiny84\FrameworkArduino\wiring_digital.c.o
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:40:18: note: suggested alternative: 'CS01'
TCCR2B = (1 << CS21); /* start timer (ck/8 prescalar) */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:41:3: error: 'TCCR2A' was not declared in this scope
TCCR2A = (1 << WGM21); /* CTC mode */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
Compiling .pio\build\attiny84\FrameworkArduino\wiring_pulse.S.o
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:41:3: note: suggested alternative: 'TCCR0A'
TCCR2A = (1 << WGM21); /* CTC mode */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:41:18: error: 'WGM21' was not declared in this scope
TCCR2A = (1 << WGM21); /* CTC mode */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:41:18: note: suggested alternative: 'WGM01'
TCCR2A = (1 << WGM21); /* CTC mode */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:42:3: error: 'OCR2A' was not declared in this scope
OCR2A = (ocr); /* We want to have at least 30Hz or else it gets choppy */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:42:3: note: suggested alternative: 'OCR0A'
OCR2A = (ocr); /* We want to have at least 30Hz or else it gets choppy */ \
Compiling .pio\build\attiny84\FrameworkArduino\wiring_pulse.c.o
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:43:3: error: 'TIMSK2' was not declared in this scope
TIMSK2 = (1 << OCIE2A); /* enable timer2 output compare match interrupt */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
Compiling .pio\build\attiny84\FrameworkArduino\wiring_shift.c.o
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:43:3: note: suggested alternative: 'TIMSK0'
TIMSK2 = (1 << OCIE2A); /* enable timer2 output compare match interrupt */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:43:18: error: 'OCIE2A' was not declared in this scope
TIMSK2 = (1 << OCIE2A); /* enable timer2 output compare match interrupt */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:43:18: note: suggested alternative: 'OCIE0A'
TIMSK2 = (1 << OCIE2A); /* enable timer2 output compare match interrupt */ \
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:171:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'
SOFTPWM_TIMER_INIT(SOFTPWM_OCR);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp: In function 'void SoftPWMSet(int8_t, uint8_t, uint8_t)':
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:37:37: error: 'TCNT2' was not declared in this scope
#define SOFTPWM_TIMER_SET(val) (TCNT2 = (val))
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:220:5: note: in expansion of macro 'SOFTPWM_TIMER_SET'
SOFTPWM_TIMER_SET(0);
^~~~~~~~~~~~~~~~~
.pio\libdeps\attiny84\SoftPWM\SoftPWM_timer.h:37:37: note: suggested alternative: 'TCNT0'
#define SOFTPWM_TIMER_SET(val) (TCNT2 = (val))
^
.pio\libdeps\attiny84\SoftPWM\SoftPWM.cpp:220:5: note: in expansion of macro 'SOFTPWM_TIMER_SET'
SOFTPWM_TIMER_SET(0);
^~~~~~~~~~~~~~~~~
*** [.pio\build\attiny84\lib978\SoftPWM\SoftPWM.cpp.o] Error 1
In file included from C:\Users\stefan\.platformio\packages\framework-arduino-avr-attiny\cores\tiny\Arduino.h:187:0,
from C:\Users\stefan\.platformio\packages\framework-arduino-avr-attiny\cores\tiny\wiring_private.h:35,
from C:\Users\stefan\.platformio\packages\framework-arduino-avr-attiny\cores\tiny\wiring_digital.c:29:
C:\Users\stefan\.platformio\packages\framework-arduino-avr-attiny\variants\tinyX4/pins_arduino.h:170:2: warning: #warning "This is the COUNTERCLOCKWISE pin mapping - make sure you're using the pinout diagram with the pins in counter clockwise order" [-Wcpp]
#warning "This is the COUNTERCLOCKWISE pin mapping - make sure you're using the pinout diagram with the pins in counter clockwise order"
^~~~~~~
I suspect that either I didn’t include the library in the correct way, or the library is not compatible with the platform, board or framework (don’t know the exact difference between these three) I’m using. As I find PlatformIO quite confusing I don’t know what to do now. Therefore any help is very much apprechiated.
Thank you!
BR,
Stefan