-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
delayMicroseconds
fails to compile with a non-constant argument
#136
Comments
@nerdralph any idea why this suddenly turned out to be a problem? It did work previously... MicroCore/avr/cores/microcore/Arduino.h Lines 118 to 143 in f1b7e29
|
delayMicroseconds
fails to compile with non constant argument delayMicroseconds
fails to compile with a non-constant argument
I've been busy with other work for the past several months, so haven't tried testing this. It certainly didn't happen with the versions of the Arduino IDE I had tested with (1.8.9 & 1.8.13). Whenever I get back to playing with embedded coding, I'll try to duplicate the problem. |
Same issue here with delayMicroseconds. I'm not a big guru of all that c-language things but looks like asm MicroCore/avr/cores/microcore/Arduino.h Line 141 in f1b7e29
|
I finally got the time to look into this, and @Bravo13 is correct. I used the wrong constraint "+d", which is for any upper register (r16-r31), but sbiw only works with the upper register pairs starting with r24, which require the "+w" constraint. When the compiler happens to pick one of those registers, it works fine, so the bug slipped through testing. |
p.s. the latest constraints are here: There was another doc referenced on avrfreaks that had more inline asm details, but I can't find it... |
Hans, have you put any thought into using submodules (or some other technique) to share common code across github repos? Just copying and pasting the text is coming back to bite me since now it needs to be fixed in at least 3 places. |
I'm using subtrees for the bootloaders and corefiles for my other Arduino cores. Personally, I wouldn't bother if you only need to change the code in two separate repos. It's pretty straight forward to set up, but if you already consider your code stable and mature, you won't save much time. I always bring up a cheat sheet every time I need to update the Arduino corefiles or bootloaders because I always forget how the command for updating a specific subtree. At first, I tried to use a submodule, which is more straightforward than a subtree, but the issue with this approach was that the submodule wasn't downloaded when the repo was downloaded as ZIP file from github.com. Cloning the repo was the only way to get everything. |
Fixed in 3c5cb93. Thanks @nerdralph! |
Hi,
While developing a small ATtiny13 based servo motor control,
I found out that
delayMicroseconds
fails to compile with non constant argument!The error message:
I found out that this line cause the error..
Also this line looks bad- what if the function is called with argument smaller than 2?
Note that the above code compiles for other ATtiny using their delayMicroseconds.
As a workaround I wrote this function, but it is not uS accurate..
@MCUdude your help here will be highly appreciated!
The text was updated successfully, but these errors were encountered: