Metro M0 and Arduino Scheduler.h Library: Warning: this inst

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
firstdown77
 
Posts: 5
Joined: Sat Feb 19, 2022 5:17 pm

Metro M0 and Arduino Scheduler.h Library: Warning: this inst

Post by firstdown77 »

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?

Image

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.
Attachments
Warning: this instruction will write back the base register.  Metro M0.
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

User avatar
firstdown77
 
Posts: 5
Joined: Sat Feb 19, 2022 5:17 pm

Re: Metro M0 and Arduino Scheduler.h Library: Warning: this

Post by firstdown77 »

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.

User avatar
firstdown77
 
Posts: 5
Joined: Sat Feb 19, 2022 5:17 pm

Re: Metro M0 and Arduino Scheduler.h Library: Warning: this

Post by firstdown77 »

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.

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Metro M0 and Arduino Scheduler.h Library: Warning: this

Post by westfw »

I believe that the assembler is complaining that the instructions used to save the register context in between tasks:

Code: Select all

	/* store low registers */
		"stmia r0, {r4-r7};"
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:

Code: Select all

	/* store low registers */
		"stmia r0!, {r4-r7};"
On a Cortex-M0, you don't have much choice. The ARM-V6m specs say:
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.
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.

I've submitted https://github.com/arduino-libraries/Sc ... /issues/17

User avatar
firstdown77
 
Posts: 5
Joined: Sat Feb 19, 2022 5:17 pm

Re: Metro M0 and Arduino Scheduler.h Library: Warning: this

Post by firstdown77 »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”