# Beispiel "PWM\_BASIC" der Lib ATtiny\_PWM wird nicht kompiliert

**URL:** <https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683>\
**Category:** Deutsch\
**Created:** [December 31, 2023, 5:16pm UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683 "2023-12-31T17:16:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![harry-th](https://avatars.discourse-cdn.com/v4/letter/h/4af34b/32.png) [@harry-th](https://forum.arduino.cc/u/harry-th)\
**Post date:** [December 31, 2023, 5:16pm UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683/1 "2023-12-31T17:16:56Z")

</div>

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:

```arduino
/ ****************************************************************************************************************************
  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
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

---

<div class="post-metadata">

**Author:** ![Doc\_Arduino](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/doc_arduino/32/215810_2.png) [@Doc\_Arduino](https://forum.arduino.cc/u/Doc_Arduino)\
**Post date:** [December 31, 2023, 5:31pm UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683/2 "2023-12-31T17:31:54Z")

</div>

Hallo,

Link zu deiner Lib?  
Ohne Pin Änderung kompiliert es?

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [December 31, 2023, 5:34pm UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683/3 "2023-12-31T17:34:54Z")

</div>

> [@harry-th](#):
>
> Arduino 1.8.13 ( wegen Benutzung von megatinycore)

Bei der 1.8.19 kann man auch das installieren, nicht das die veraltet ist

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [December 31, 2023, 7:58pm UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683/4 "2023-12-31T19:58:12Z")

</div>

IDE so einstellen.

Wenn es das auch auf deutsch gibt bitte link posten.  
Hab danach gesucht bin aber nicht fündig geworden

> **[Use verbose output in the Arduino IDE](https://support.arduino.cc/hc/en-us/articles/4407705216274-Use-verbose-output-in-the-Arduino-IDE)**
>
> Enabling verbose output will output more detailed information in the console. This is useful for troubleshooting errors during compilation or upload.
> Enable verbose output
> Verbose output is enabled...

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [December 31, 2023, 8:05pm UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683/5 "2023-12-31T20:05:36Z")

</div>

Meinst das hier?

> **[ATtiny Cores für Arduino IDE 1.8.x einrichten - Elektronik \[Dokumentation und...](https://www.modellbahn-doku.de/elektronik/attiny_cores_fuer_arduino_ide_1.8.x)**
>
> ATtiny Cores für Arduino IDE 1.8.x einrichten Es gibt zwei Cores für die Arduino IDE, die gut funktionieren. Die Version von SpenceKonde deckt einige ATtinys ab und kann gut verwenbdet werden. Als weitere Lösung gibt es noch die von Damellis, welche...

Guten Rutsch 😉

---

<div class="post-metadata">

**Author:** ![Kai-R](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kai-r/32/801182_2.png) [@Kai-R](https://forum.arduino.cc/u/Kai-R)\
**Post date:** [December 31, 2023, 9:03pm UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683/6 "2023-12-31T21:03:02Z")

</div>

Das Programm passt schlichtweg nicht in den Speicher vom 412er... (Steht auch in Deiner Fehlermeldung: arduino\_build\_680113/PWM\_Basic.ino.elf section `.text' is not within region `text')

Wenn man den Code in der loop() Auskommentiert und in der setup() sämtliche Serial Zeilen ebenfalls, verbraucht das Programm schon

```arduino
RAM: [===] 30.1% (used 77 bytes from 256 bytes)
Flash: [=========] 93.2% (used 3817 bytes from 4096 bytes)
=============================================================== [SUCCESS] Took 3.51 seconds =====

```

Für einen ATtiny1614 compiliert

```arduino
RAM: [=] 8.5% (used 175 bytes from 2048 bytes)
Flash: [====] 38.3% (used 6279 bytes from 16384 bytes)
Building .pio\build\ATtiny1614\firmware.hex
=============================================================== [SUCCESS] Took 6.17 seconds 

```

Es wäre wohl empfehlenswert diese Lib nicht zu verwenden und das PWM zu Fuß zu programmieren.

Und da passt noch etwas nicht. In dem Code den Du gepostet hast, ist BOARD\_NAME nicht definiert.

Hier findest Du Beispielcodes zur PWM Programmierung:

> <https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/TakingOverTCA0.md#example-2-variable-frequency-and-duty-cycle-pwm>

---

<div class="post-metadata">

**Author:** ![Plumps](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/plumps/32/1018546_2.png) [@Plumps](https://forum.arduino.cc/u/Plumps)\
**Post date:** [January 1, 2024, 7:51am UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683/7 "2024-01-01T07:51:22Z")

</div>

Wahnsinn das die Lib für etwas PWM soviel Speicher braucht. Vor allem da die ATTinys ja eher die sind, die weniger davon zur Verfügung haben.

---

<div class="post-metadata">

**Author:** ![harry-th](https://avatars.discourse-cdn.com/v4/letter/h/4af34b/32.png) [@harry-th](https://forum.arduino.cc/u/harry-th)\
**Post date:** [January 1, 2024, 9:48am UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683/8 "2024-01-01T09:48:39Z")

</div>

ich danke euch allen für die guten Tips.  
Ja, es ist schade, dass diese Lib soviel Speicher verbraucht und ich werde wohl dem Rat von Kai-R folgen, und die PWM zu Fuß programmieren, da ja auch noch zusätzlicher Code für die geplante Funktion benötigt wird.  
Zur info für euch:  
Ich habe eine LED Deckenlampe gekauft, die über eine Fernbedienung in Helligkeit und Farbtemperatur eingestellt werden kann.  
Leider mußte ich feststellen, dass die Lampe den eingestellten Zustand vergißt, wenn man sie über den Lichtschalter ausschaltet.  
Ich habe dann das Netzteil analysiert und festgestellt, dass da anscheinend ein kundenspezifischer Chip verwendet wird. Den will ich ersetzen und der ATTiny412 passt genau ins Layout.  
Das Einlesen der FB-Codes funktioniert schon und jetzt fehlt eben noch die Ausgabe von 2 PWM Signalen (4kHz, 8% -100%), da die Einstellung der Farbtemperatur einfach über die unterschiedliche Ansteuerung von 2 verschiedenfarbigen LED-Ketten erfolgt.

Nochmal vielen Dank

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 29, 2024, 9:48am UTC](https://forum.arduino.cc/t/beispiel-pwm-basic-der-lib-attiny-pwm-wird-nicht-kompiliert/1205683/9 "2024-06-29T09:48:42Z")

</div>

Closed on June 29, 2024, 9:48am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
