nerdralph / picoCore

size-optimized Arduino/Wiring core for tiny AVR MCUs
MIT License
28 stars 4 forks source link

Delay not to require constant at compile time #2

Closed Kaspi314 closed 3 years ago

Kaspi314 commented 3 years ago

I'm getting this error trying to use a dynamic delay (int) in delayMicroseconds.

Please support dynamic delay or delayMicroseconds.

I can just poll current time as a workaround in a while loop and compare but this should be somehow included in a way that is clock accurate and supports a dynamic delay.

Arduino: 1.8.12 (Windows 10), Board: "picoCore, ATtiny85"

C:\Users\trusted\Downloads\arduino-1.8.12\arduino-builder -dump-prefs -logger=machine -hardware C:\Users\trusted\Downloads\arduino-1.8.12\hardware -hardware C:\Users\trusted\AppData\Local\Arduino15\packages -hardware C:\Users\trusted\Documents\Arduino\hardware -tools C:\Users\trusted\Downloads\arduino-1.8.12\tools-builder -tools C:\Users\trusted\Downloads\arduino-1.8.12\hardware\tools\avr -tools C:\Users\trusted\AppData\Local\Arduino15\packages -built-in-libraries C:\Users\trusted\Downloads\arduino-1.8.12\libraries -libraries C:\Users\trusted\Documents\Arduino\libraries -fqbn=picoCore-0.3.0:avr:picocore:mcu=t85 -ide-version=10812 -build-path C:\Users\trusted\AppData\Local\Temp\arduino_build_279929 -warnings=none -build-cache C:\Users\trusted\AppData\Local\Temp\arduino_cache_898403 -prefs=build.warn_data_percentage=75 -verbose 

....

Compiling core...
Using precompiled core: C:\Users\trusted\AppData\Local\Temp\arduino_cache_898403\core\core_picoCore-0.3.0_avr_picocore_mcu_t85_3976ebd4312f7578e159f4abd8f0d200.a
Linking everything together...
"C:\\Users\\trusted\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -flto -fno-reorder-blocks -ffixed-r2 -ffixed-r3 -ffixed-r4 -g -fuse-linker-plugin -Wl,--gc-sections -mrelax -mmcu=attiny85 -nostartfiles -Wl,--undefined=__vectors -Wl,--section-start=.bootloader=0x1f00 -o "C:\\Users\\trusted\\AppData\\Local\\Temp\\arduino_build_279929/PicoSerialT.ino.elf" "C:\\Users\\trusted\\AppData\\Local\\Temp\\arduino_build_279929\\sketch\\pu_print.c.o" "C:\\Users\\trusted\\AppData\\Local\\Temp\\arduino_build_279929\\sketch\\PicoSerialT.ino.cpp.o" "C:\\Users\\trusted\\AppData\\Local\\Temp\\arduino_build_279929\\sketch\\picoUART.cpp.o" "C:\\Users\\trusted\\AppData\\Local\\Temp\\arduino_build_279929\\sketch\\rxISR.cpp.o" "C:\\Users\\trusted\\AppData\\Local\\Temp\\arduino_build_279929\\libraries\\picoUART-1.1.1\\picoUART-1.1.1.a" "C:\\Users\\trusted\\AppData\\Local\\Temp\\arduino_build_279929/..\\arduino_cache_898403\\core\\core_picoCore-0.3.0_avr_picocore_mcu_t85_3976ebd4312f7578e159f4abd8f0d200.a" "-LC:\\Users\\trusted\\AppData\\Local\\Temp\\arduino_build_279929" -lm
c:\users\trusted\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\util\delay.h: In function 'main':

c:\users\trusted\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\util\delay.h:276:2: error: __builtin_avr_delay_cycles expects a compile time integer constant

  __builtin_avr_delay_cycles(__ticks_dc);

  ^

lto-wrapper.exe: fatal error: C:\Users\trusted\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/users/trusted/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

Using library picoUART-1.1.1 at version 1.0.0 in folder: C:\Users\trusted\Documents\Arduino\libraries\picoUART-1.1.1 
exit status 1
Error compiling for board picoCore.
nerdralph commented 3 years ago

I implemented this change a few months ago. I was waiting to finish v0.4.0 before publishing a new release, but since you asked I decided to release v0.3.5 in the interim. https://github.com/nerdralph/picoCore/releases/tag/v0.3.5

Kaspi314 commented 3 years ago

I must have read that and I missed it but this helps a ton.

I had tried with the macro#define __DELAY_BACKWARD_COMPATIBLE__

it actually compiled once but after restarting arduino it would not compile. (I guess avr gcc is quirky about restarting sometimes and it should always be restarted to test changes before committing.)