I am hoping to introduce some sort of concurrency in my new Metro M0 project however when I tried to compile the example Scheduler.h sketch MultipleBlinks I see this assembler warning: Warning: this instruction will write back the base register. If I upload this program to the Metro M0 will something bad happen? Better question - does anyone know what this warning means?
The Scheduler library was written for SAMD21 Arduinos like the Arduino Zero and Due. Since the Metro M0 has the same chip I thought the same library should work.
Metro M0 and Arduino Scheduler.h Library: Warning: this inst
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- firstdown77
- Posts: 5
- Joined: Sat Feb 19, 2022 5:17 pm
Metro M0 and Arduino Scheduler.h Library: Warning: this inst
- Attachments
-
- Warning: this instruction will write back the base register. Metro M0.
- Scheduler Adafruit Instruction Write Back Base Register Highlighted.png (291.23 KiB) Viewed 173 times
- firstdown77
- Posts: 5
- Joined: Sat Feb 19, 2022 5:17 pm
Re: Metro M0 and Arduino Scheduler.h Library: Warning: this
I can see the example sketch compiles fine on Metro M4. Maybe I should pick one up instead of dig through this warning on Metro M0.
- firstdown77
- Posts: 5
- Joined: Sat Feb 19, 2022 5:17 pm
Re: Metro M0 and Arduino Scheduler.h Library: Warning: this
I identified that the Scheduler library compiles for the Metro M0 with the Adafruit SAMD Boards Arduino library up to version 1.7.5 (September 2021). It starts compiling with scary warnings starting in version 1.7.6 (January 2022). I downgraded to 1.7.5 and should be all set.
- westfw
- Posts: 2008
- Joined: Fri Apr 27, 2007 1:01 pm
Re: Metro M0 and Arduino Scheduler.h Library: Warning: this
I believe that the assembler is complaining that the instructions used to save the register context in between tasks:
will write back the modified address to r0. This is actually the desired behavior, so the warnings can be ignored.
The code should be using the "write-back" suffix:
On a Cortex-M0, you don't have much choice. The ARM-V6m specs say:
I've submitted https://github.com/arduino-libraries/Sc ... /issues/17
Code: Select all
/* store low registers */
"stmia r0, {r4-r7};"
The code should be using the "write-back" suffix:
Code: Select all
/* store low registers */
"stmia r0!, {r4-r7};"
Um. This may mean that the scheduler library does not work properly on SAMD51 boards, since those processors are AVR-v7m which DOES have both write-back and non-write-back versions of the instruction.the writeback suffix must always be used unless the instruction is an LDM where reglist also contains Rn, in which case the writeback suffix must not be used.
I've submitted https://github.com/arduino-libraries/Sc ... /issues/17
- firstdown77
- Posts: 5
- Joined: Sat Feb 19, 2022 5:17 pm
Re: Metro M0 and Arduino Scheduler.h Library: Warning: this
Thanks. After realizing that there is inline assembly code in that Scheduler library, I think I am going to abandon that official Scheduler library for mikaelpatel's Arduino-Scheduler. There is a long thread that elaborates on why it is better than the official Scheduler (https://forum.arduino.cc/t/simple-ardui ... ler/358699). It is too bad the official Scheduler is so experimental.
Please be positive and constructive with your questions and comments.