Hallo,
ich versuche gerade, auf einem ATTiny412 das Beispiel PWM_BASIC aus der Library ATtiny_PWM zum Laufen zu bringen.
Den ATTIny412 verwende ich wegen notwendiger pinout Kompatibilität (VCC, GND) in einem existierenden PCB Layout
Meine Umgebung:
Arduino 1.8.13 ( wegen Benutzung von megatinycore)
Library ATTiny_PWM installiert
ATTiny412 in Programmieradapter
UPDI-Programmieradapter mit FTDI USB to serial adapter und RX/TX to UPDI Schaltung
Hier der code:
/****************************************************************************************************************************
PWM_Basic.ino
For Arduino AVR ATtiny-based boards (ATtiny3217, etc.) using megaTinyCore
Written by Khoi Hoang
Built by Khoi Hoang https://github.com/khoih-prog/ATtiny_PWM
Licensed under MIT license
*****************************************************************************************************************************/
#define _PWM_LOGLEVEL_ 4
// Select false to use PWM
#define USING_TIMER false //true
#include "ATtiny_PWM.h"
/*
const uint8_t digital_pin_to_timer[] = {
// Left side, top to bottom
TIMERA0, // 0 PA4 WO4 WOA
TIMERA0, // 1 PA5 WO5 WOB
#if defined(DAC0)
DACOUT, // 2 PA6
#else
NOT_ON_TIMER, // 2 PA6
#endif
NOT_ON_TIMER, // 3 PA7
NOT_ON_TIMER, // 4 PB7
NOT_ON_TIMER, // 5 PB6
NOT_ON_TIMER, // 6 PB5 WO2 Alt
NOT_ON_TIMER, // 7 PB4 WO1 Alt
NOT_ON_TIMER, // 8 PB3 WO0 Alt
TIMERA0, // 9 PB2 WO2
TIMERA0, // 10 PB1 WO1
// Right side, bottom to top
TIMERA0, // 11 PB0 WO0
#if (defined(TCD0) && defined(USE_TIMERD0_PWM))
TIMERD0, // 12 PC0 WOC
TIMERD0, // 13 PC1 WOD
#else
NOT_ON_TIMER, // 12 PC0
NOT_ON_TIMER, // 13 PC1
#endif
NOT_ON_TIMER, // 14 PC2
NOT_ON_TIMER, // 15 PC3 WO3 Alt
NOT_ON_TIMER, // 16 PC4 WO4 Alt
NOT_ON_TIMER, // 17 PC5 WO5 Alt
NOT_ON_TIMER, // 18 PA1
NOT_ON_TIMER, // 19 PA2
TIMERA0, // 20 PA3 WO3
NOT_ON_TIMER // 21 PA0
};
*/
// OK, only PIN_PA4-5:TCA0
// PIN_PC0-1: TCD0 => not OK yet for frequency
// Not OK, PIN_PA6, 7, PIN_PB0-2:TCA0
#define pinToUse PIN_PA3 //PIN_PB4
//creates pwm instance
ATtiny_PWM* PWM_Instance;
float frequency = 1000.0f;
float dutyCycle = 0.0f;
void setup()
{
Serial.begin(115200);
while (!Serial && millis() < 5000);
delay(500);
Serial.print(F("\nStarting PWM_Basic using PWM on "));
Serial.println(BOARD_NAME);
Serial.println(AT_TINY_PWM_VERSION);
//assigns PWM frequency of 1.0 KHz and a duty cycle of 0%
PWM_Instance = new ATtiny_PWM(pinToUse, frequency, dutyCycle);
if ( (!PWM_Instance) || !PWM_Instance->isPWMEnabled())
{
Serial.print(F("Stop here forever"));
while (true)
delay(10000);
}
}
void loop()
{
// You can change frequency here, anytime
frequency = 2000.0f;
//frequency = 20.0f;
dutyCycle = 20.0f;
PWM_Instance->setPWM(pinToUse, frequency, dutyCycle);
analogWrite(PIN_PA3, dutyCycle * (1 << 8) / 100);
delay(10000);
// You can change frequency here, anytime
frequency = 5000.0f;
//frequency = 50.0f;
dutyCycle = 90.0f;
PWM_Instance->setPWM(pinToUse, frequency, dutyCycle);
analogWrite(PIN_PA3, dutyCycle * (1 << 8) / 100);
//while (1)
delay(10000);
}
Die einzige Änderung, die ich gemacht habe, ist
#define pinToUse PIN_PA5 -> #define pinToUse PIN_PA3
und hier die Fehlermeldungen:
Arduino: 1.8.13 (Windows 10), Board: "ATtiny412/402/212/202, ATtiny412, 20 MHz internal, 1.8V (5 MHz or less), Disabled/Disabled, EEPROM retained, Enabled (default timer), 8ms, Master or Slave (saves flash and RAM), Default (doesn't print floats, 1.4k flash use), PA1-3,7 (default), On all pins, with new implementation., Disabled (recommended), No delay before window "opens""
F:\Users\harry\Arduino 1.8.13\arduino-builder -dump-prefs -logger=machine -hardware F:\Users\harry\Arduino 1.8.13\hardware -hardware F:\Users\harry\AppData\Local\Arduino15\packages -tools F:\Users\harry\Arduino 1.8.13\tools-builder -tools F:\Users\harry\Arduino 1.8.13\hardware\tools\avr -tools F:\Users\harry\AppData\Local\Arduino15\packages -built-in-libraries F:\Users\harry\Arduino 1.8.13\libraries -libraries F:\Users\harry\Documents\Arduino\libraries -fqbn=megaTinyCore:megaavr:atxy2:chip=412,clock=20internal,bodvoltage=1v8,bodmode=disabled,eesave=enable,millis=enabled,startuptime=8,wiremode=mors,printf=default,PWMmux=default,attach=allenabled,WDTtimeout=disabled,WDTwindow=disabled -ide-version=10813 -build-path F:\Users\harry\AppData\Local\Temp\arduino_build_680113 -warnings=default -build-cache F:\Users\harry\AppData\Local\Temp\arduino_cache_913843 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=F:\Users\harry\AppData\Local\Arduino15\packages\DxCore\tools\avrdude\6.3.0-arduino17or18 -prefs=runtime.tools.avrdude-6.3.0-arduino17or18.path=F:\Users\harry\AppData\Local\Arduino15\packages\DxCore\tools\avrdude\6.3.0-arduino17or18 -prefs=runtime.tools.arduinoOTA.path=F:\Users\harry\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=F:\Users\harry\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.python3.path=F:\Users\harry\AppData\Local\Arduino15\packages\megaTinyCore\tools\python3\3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=F:\Users\harry\AppData\Local\Arduino15\packages\megaTinyCore\tools\python3\3.7.2-post1 -prefs=runtime.tools.avr-gcc.path=F:\Users\harry\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino7b1 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-azduino7b1.path=F:\Users\harry\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino7b1 -verbose F:\Users\harry\AppData\Local\Temp\arduino_modified_sketch_35528\PWM_Basic.ino
F:\Users\harry\Arduino 1.8.13\arduino-builder -compile -logger=machine -hardware F:\Users\harry\Arduino 1.8.13\hardware -hardware F:\Users\harry\AppData\Local\Arduino15\packages -tools F:\Users\harry\Arduino 1.8.13\tools-builder -tools F:\Users\harry\Arduino 1.8.13\hardware\tools\avr -tools F:\Users\harry\AppData\Local\Arduino15\packages -built-in-libraries F:\Users\harry\Arduino 1.8.13\libraries -libraries F:\Users\harry\Documents\Arduino\libraries -fqbn=megaTinyCore:megaavr:atxy2:chip=412,clock=20internal,bodvoltage=1v8,bodmode=disabled,eesave=enable,millis=enabled,startuptime=8,wiremode=mors,printf=default,PWMmux=default,attach=allenabled,WDTtimeout=disabled,WDTwindow=disabled -ide-version=10813 -build-path F:\Users\harry\AppData\Local\Temp\arduino_build_680113 -warnings=default -build-cache F:\Users\harry\AppData\Local\Temp\arduino_cache_913843 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=F:\Users\harry\AppData\Local\Arduino15\packages\DxCore\tools\avrdude\6.3.0-arduino17or18 -prefs=runtime.tools.avrdude-6.3.0-arduino17or18.path=F:\Users\harry\AppData\Local\Arduino15\packages\DxCore\tools\avrdude\6.3.0-arduino17or18 -prefs=runtime.tools.arduinoOTA.path=F:\Users\harry\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=F:\Users\harry\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.python3.path=F:\Users\harry\AppData\Local\Arduino15\packages\megaTinyCore\tools\python3\3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=F:\Users\harry\AppData\Local\Arduino15\packages\megaTinyCore\tools\python3\3.7.2-post1 -prefs=runtime.tools.avr-gcc.path=F:\Users\harry\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino7b1 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-azduino7b1.path=F:\Users\harry\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino7b1 -verbose F:\Users\harry\AppData\Local\Temp\arduino_modified_sketch_35528\PWM_Basic.ino
Using board 'atxy2' from platform in folder: F:\Users\harry\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10
Using core 'megatinycore' from platform in folder: F:\Users\harry\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10
Detecting libraries used...
"F:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\DxCore\\tools\\avr-gcc\\7.3.0-atmel3.6.1-azduino7b1/bin/avr-g++" -c -g -Os -Wall -std=gnu++17 -fpermissive -Wno-sized-deallocation -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=attiny412 -DF_CPU=20000000L -DCLOCK_SOURCE=0 -DTWI_MORS -DMILLIS_USE_TIMERD0 -DCORE_ATTACH_ALL -DTCA_PORTMUX=0x01 -DARDUINO=10813 -DARDUINO_AVR_ATtiny412 -DARDUINO_ARCH_MEGAAVR "-DMEGATINYCORE=\"2.6.10\"" -DMEGATINYCORE_MAJOR=2UL -DMEGATINYCORE_MINOR=6UL -DMEGATINYCORE_PATCH=10UL -DMEGATINYCORE_RELEASED=1 -DARDUINO_attinyxy2 "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\cores\\megatinycore/api/deprecated" "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\cores\\megatinycore" "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\variants\\txy2" "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113\\sketch\\PWM_Basic.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for ATtiny_PWM.h: [ATtiny_PWM@1.2.0]
ResolveLibrary(ATtiny_PWM.h)
-> candidates: [ATtiny_PWM@1.2.0]
"F:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\DxCore\\tools\\avr-gcc\\7.3.0-atmel3.6.1-azduino7b1/bin/avr-g++" -c -g -Os -Wall -std=gnu++17 -fpermissive -Wno-sized-deallocation -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=attiny412 -DF_CPU=20000000L -DCLOCK_SOURCE=0 -DTWI_MORS -DMILLIS_USE_TIMERD0 -DCORE_ATTACH_ALL -DTCA_PORTMUX=0x01 -DARDUINO=10813 -DARDUINO_AVR_ATtiny412 -DARDUINO_ARCH_MEGAAVR "-DMEGATINYCORE=\"2.6.10\"" -DMEGATINYCORE_MAJOR=2UL -DMEGATINYCORE_MINOR=6UL -DMEGATINYCORE_PATCH=10UL -DMEGATINYCORE_RELEASED=1 -DARDUINO_attinyxy2 "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\cores\\megatinycore/api/deprecated" "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\cores\\megatinycore" "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\variants\\txy2" "-IF:\\Users\\harry\\Documents\\Arduino\\libraries\\ATtiny_PWM\\src" "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113\\sketch\\PWM_Basic.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Generating function prototypes...
"F:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\DxCore\\tools\\avr-gcc\\7.3.0-atmel3.6.1-azduino7b1/bin/avr-g++" -c -g -Os -Wall -std=gnu++17 -fpermissive -Wno-sized-deallocation -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=attiny412 -DF_CPU=20000000L -DCLOCK_SOURCE=0 -DTWI_MORS -DMILLIS_USE_TIMERD0 -DCORE_ATTACH_ALL -DTCA_PORTMUX=0x01 -DARDUINO=10813 -DARDUINO_AVR_ATtiny412 -DARDUINO_ARCH_MEGAAVR "-DMEGATINYCORE=\"2.6.10\"" -DMEGATINYCORE_MAJOR=2UL -DMEGATINYCORE_MINOR=6UL -DMEGATINYCORE_PATCH=10UL -DMEGATINYCORE_RELEASED=1 -DARDUINO_attinyxy2 "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\cores\\megatinycore/api/deprecated" "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\cores\\megatinycore" "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\variants\\txy2" "-IF:\\Users\\harry\\Documents\\Arduino\\libraries\\ATtiny_PWM\\src" "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113\\sketch\\PWM_Basic.ino.cpp" -o "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE
"F:\\Users\\harry\\Arduino 1.8.13\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Sketch wird kompiliert...
"F:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\DxCore\\tools\\avr-gcc\\7.3.0-atmel3.6.1-azduino7b1/bin/avr-g++" -c -g -Os -Wall -std=gnu++17 -fpermissive -Wno-sized-deallocation -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=attiny412 -DF_CPU=20000000L -DCLOCK_SOURCE=0 -DTWI_MORS -DMILLIS_USE_TIMERD0 -DCORE_ATTACH_ALL -DTCA_PORTMUX=0x01 -DARDUINO=10813 -DARDUINO_AVR_ATtiny412 -DARDUINO_ARCH_MEGAAVR "-DMEGATINYCORE=\"2.6.10\"" -DMEGATINYCORE_MAJOR=2UL -DMEGATINYCORE_MINOR=6UL -DMEGATINYCORE_PATCH=10UL -DMEGATINYCORE_RELEASED=1 -DARDUINO_attinyxy2 "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\cores\\megatinycore/api/deprecated" "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\cores\\megatinycore" "-IF:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\megaTinyCore\\hardware\\megaavr\\2.6.10\\variants\\txy2" "-IF:\\Users\\harry\\Documents\\Arduino\\libraries\\ATtiny_PWM\\src" "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113\\sketch\\PWM_Basic.ino.cpp" -o "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113\\sketch\\PWM_Basic.ino.cpp.o"
Compiling libraries...
Compiling library "ATtiny_PWM"
Compiling core...
Using precompiled core: F:\Users\harry\AppData\Local\Temp\arduino_cache_913843\core\core_4ad95cab9f7ec9aa0a1d9563d0097324.a
Linking everything together...
"F:\\Users\\harry\\AppData\\Local\\Arduino15\\packages\\DxCore\\tools\\avr-gcc\\7.3.0-atmel3.6.1-azduino7b1/bin/avr-gcc" -Wall -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -Wl,--section-start=.text=0x0 -mmcu=attiny412 -o "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113/PWM_Basic.ino.elf" "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113\\sketch\\PWM_Basic.ino.cpp.o" "F:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113/..\\arduino_cache_913843\\core\\core_4ad95cab9f7ec9aa0a1d9563d0097324.a" "-LF:\\Users\\harry\\AppData\\Local\\Temp\\arduino_build_680113" -lm
f:/users/harry/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: address 0x158c of F:\Users\harry\AppData\Local\Temp\arduino_build_680113/PWM_Basic.ino.elf section `.text' is not within region `text'
f:/users/harry/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: F:\Users\harry\AppData\Local\Temp\arduino_build_680113/PWM_Basic.ino.elf section `.rodata' will not fit in region `text'
f:/users/harry/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: address 0x158c of F:\Users\harry\AppData\Local\Temp\arduino_build_680113/PWM_Basic.ino.elf section `.text' is not within region `text'
f:/users/harry/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: region `text' overflowed by 1677 bytes
f:/users/harry/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avrxmega3/short-calls/crtattiny412.o:../../../../../crt1/gcrt1.S:315:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in f:/users/harry/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/avrxmega3/short-calls\libgcc.a(_exit.o)
f:/users/harry/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/avrxmega3/short-calls\libgcc.a(_ctors.o): In function `__do_global_ctors':
/home/admin/Arduino/toolchain-avr-special-master/gcc-build/avr/avrxmega3/short-calls/libgcc/../../../../../gcc/libgcc/config/avr/lib1funcs.S:2481:(.init6+0xc): relocation truncated to fit: R_AVR_13_PCREL against symbol `__tablejump2__' defined in .text.libgcc section in f:/users/harry/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/avrxmega3/short-calls\libgcc.a(_tablejump2.o)
collect2.exe: error: ld returned 1 exit status
Bibliothek ATtiny_PWM in Version 1.2.0 im Ordner: F:\Users\harry\Documents\Arduino\libraries\ATtiny_PWM wird verwendet
exit status 1
Fehler beim Kompilieren für das Board ATtiny412/402/212/202.
Vielleicht stehe ich nur am Schlauch und es ist nur eine Kleinigkeit, denn ich kann mir nicht vorstellen, dass da in nicht lauffähiges Beispiel mit der Lib ausgeliefert wird, aber ich komm nicht weiter und bitte höflich um Erleuchtung.
Vielen Dank vorab
Harry