Функция yield() и ошибка: Error: constant value required

Святослав Хусамов

✩✩✩✩✩✩✩
3 Фев 2021
2
0
Здравствуйте!

При компиляции появляется ошибка "Error: constant value required".
Она исчезает, если из сприпта убрать вызов yield(). Но этот вызов нужен для библиотеки <Scheduler.h>.

Как это исправить?

Привожу листинг вывода при компиляции:
Компиляция:
 Executing task in folder 210202-083254-uno: C:\Users\khusamov\.platformio\penv\Scripts\pio.exe run <

Processing uno (platform: atmelavr; board: uno; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via [ICODE]-v, --verbose[/ICODE] option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (3.1.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
[LIST]
[*]framework-arduino-avr 5.1.0
[*]toolchain-atmelavr 1.50400.190710 (5.4.0)
[/LIST]
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...  
Dependency Graph
|-- <Scheduler> 0.4.4
|-- <bmp085>
|   |-- <Wire> 1.0  
|-- <dht11> 0.4.1    
|-- <LiquidCrystalRus>
Building in release mode
Compiling .pio\build\uno\src\Meteo_v1.cpp.o
Linking .pio\build\uno\firmware.elf
C:\Users\khusamov\AppData\Local\Temp\ccOWBOlh.s: Assembler messages:
C:\Users\khusamov\AppData\Local\Temp\ccOWBOlh.s:2178: Error: constant value required
lto-wrapper.exe: fatal error: avr-g++ returned 1 exit status
compilation terminated.
c:/users/khusamov/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\uno\firmware.elf] Error 1
=========================================================================================================================================== [FAILED] Took 2.06 seconds ===========================================================================================================================================The terminal process "C:\Users\khusamov\.platformio\penv\Scripts\pio.exe 'run'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.
Также привожу сам скрипт:

Скрипт:
#include <Scheduler.h>

int led1 = 13;
int led2 = 12;
int led3 = 11;

void loop2();
void loop3();

void setup() {
  Serial.begin(9600);

  // Setup the 3 pins as OUTPUT
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

  // Add "loop2" and "loop3" to scheduling.
  // "loop" is always started by default.
  Scheduler.startLoop(loop2);
  Scheduler.startLoop(loop3);
}

// Task no.1: blink LED with 1 second delay.
void loop() {
  digitalWrite(led1, HIGH);

  // IMPORTANT:
  // When multiple tasks are running 'delay' passes control to
  // other tasks while waiting and guarantees they get executed.
  delay(1000);

  digitalWrite(led1, LOW);
  delay(1000);
}

// Task no.2: blink LED with 0.1 second delay.
void loop2() {
  digitalWrite(led2, HIGH);
  delay(100);
  digitalWrite(led2, LOW);
  delay(100);
}

// Task no.3: accept commands from Serial port
// '0' turns off LED
// '1' turns on LED
void loop3() {
  if (Serial.available()) {
    char c = Serial.read();
    if (c == '0') {
      digitalWrite(led3, LOW);
      Serial.println("Led turned off!");
    }
    if (c == '1') {
      digitalWrite(led3, HIGH);
      Serial.println("Led turned on!");
    }
  }

  // IMPORTANT:
  // We must call 'yield' at a regular basis to pass
  // control to other tasks.
  yield();
}
 

IamNikolay

★★★✩✩✩✩
15 Янв 2020
820
175