jensgrabner / digitalwritefast Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/digitalwritefast
Automatically exported from code.google.com/p/digitalwritefast
What steps will reproduce the problem?
1. Code :
[code]
digitalWriteFast(MY_PIN, HIGH);
digitalWriteFast(MY_PIN, LOW);
[/code]
in my case, MY_PIN was set to 28.
2. Build flags
Use -O3 for optimized code
What is the expected output? What do you see instead?
The expected output would a pulse on the PIN. Instead, the code is purely and
simply removed by the optimizer. This is expected since the 2nd statement
"cancels" the 1st one, and the optimizer can see that.
In order to fix this, one should add the "volatile" keyword in the
"digitalWriteFast" macro definition (instead of casting to uint8_t* the cast on
line 134 should be to "volatile uint8_t*). This keyword tells the optimizer
that the referenced variable has a "meaning" outside of the program (i.e. it
can be modified by an external source, or its modifications affect the outside
world). It is a good practice (if not mandatory) to add this keyword to
anything that act as a register.
By the way, the macro _MMIO_BYTE in sfr_defs.h:128 uses volatile : the problem
actually resides in the cast, which removes it.
The modification was successfully tested.
the fix should be added to the following macros :
-pinModeFast
-digitalWriteFast
-noAnalogWrite
-digitalReadFast (not sure : there is no cast here, so the keyword from
_MMIO_BYTE is not removed)
What version of the product are you using? On what operating system?
avr-gcc (Fedora 4.7.2-1.fc17) 4.7.2
Please provide any additional information below.
Great work on this library!
By the way, I use it for 8 bit parallel transfers. So I added some macros
(digitalWriteFastPort, portModeFast, digitalReadFastPort) which make those
8-bit reads in 1 single instruction : this may be a good addition to your
library. The only constraint on this is that the user must ensure that its 8
IOs are on the same port, but it allows a rather fast communication.
Frederic.
Original issue reported on code.google.com by [email protected]
on 28 Dec 2012 at 2:36
The project is all set up for SVN, yet the repository seems to be empty.
Why is this project not under SVN control?
That way everyone can see an track the changes.
Original issue reported on code.google.com by [email protected]
on 6 Nov 2011 at 9:03
is there any way to make #define'd pins under your library?
for example;
#define DAT_PIN = 21
wouldn't this be the same as; fastDigitalWrite(21,LO)?
Original issue reported on code.google.com by [email protected]
on 2 Feb 2011 at 12:38
#define sclk 52
digitalWriteFast(sclk, HIGH);
12c6: 85 b1 in r24, 0x05 ; 5
12c8: 82 60 ori r24, 0x02 ; 2
asm volatile("nop \n\tnop \n\t");
12ca: 00 00 nop
12cc: 00 00 nop
digitalWriteFast(sclk, LOW);
12ce: 8d 7f andi r24, 0xFD ; 253
12d0: 85 b9 out 0x05, r24 ; 5
after much research, this issue is that the __atomicWrite__ function is missing
volatile casts on the first parameter to bitWrite which is causing the compiler
to do various optimizations.
Attached is a correct version of the code. I've removed the (uint8_t*) casts
in the digital macros and just placed them in the atomicWrite macro
Original issue reported on code.google.com by [email protected]
on 4 Aug 2011 at 6:08
Attachments:
WProgram.h is no longer in Arduino 1.0.
The following change for header files seems to work on 0022 and 1.0.
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include "WProgram.h"
#include <wiring.h>
#endif
Original issue reported on code.google.com by [email protected]
on 24 Dec 2011 at 2:04
Attempt to use DigitalReadFast on an Arduino Leonardo
Line using digital read fast, which compiles on Uno..
if (digitalReadFast(HomeSwitch) == HIGH){
gives error
'TCCR2A' was not declared in this scope
'COM2A1' was not declared in this scope
and so on.
Using Windows 7, Arduino 1.5
Thinking that this may have something to do with the different port mappings on
the Arduino Leonardo and not having updates to this library.
Original issue reported on code.google.com by [email protected]
on 9 Jul 2013 at 3:36
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.