Skip to content
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

fast pin access #449

Merged
merged 2 commits into from
Jun 13, 2015
Merged

fast pin access #449

merged 2 commits into from
Jun 13, 2015

Conversation

m-mcgowan
Copy link
Contributor

This covers fast pin set/reset. Does anyone have a suggestion for multiple pin set/reset, port access etc..?

@satishgn
Copy link
Contributor

Yes. Bit-banding is available on ARM Cortex-M3 which is the fastest/atomic way to set/reset IO pins.
Please feel free to assign it to me. I can take this up in my spare time after hardware design.
For more info on this: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337h/Behcjiic.html

@m-mcgowan
Copy link
Contributor Author

Good call satish - right now focus is primarily on the API (as you see the implementation is simple), when that API settles down feel free to add a bit-banding implementation if you wish. I'm curious exactly how much faster bit banding will be and how fast do we need it to be?

@ScruffR
Copy link
Contributor

ScruffR commented Jun 10, 2015

May be a bit late, but for consistency with digitalWriteFast() would not pinSetFast()/pinResetFast() be "nicer" ;-)

About bit-banding, I had used this macro in an RGBMatrixPanel lib together with Paul
#define portSetMasked(_port, _word, _mask) (_port->BSRR = (_mask << 16) | (_word & _mask))

It`s not quite bit-banding, but it's atomic and somewhat fast too.

http://community.particle.io/t/some-reusable-macros-and-stuff/8846

I did some timing tests on the interrupt routine that does other things too, but the port write was notably faster.

http://community.particle.io/t/adafruit-16x32-rgb-led-matrix/5119/107

@technobly
Copy link
Member

Yep, Mat made them all consistent with Fast at the end.

I'm pretty excited about this bit-banding thing... have not experimented with that but it sounds super powerful for fast access.

@pkourany
Copy link
Contributor

Oh, I like the bit banding. Nice catch @satishgn. @ScruffR, the whole port write IS fast and doing it with bit banding would not be faster IMO. But for single bit operations, to the user, it would be transparent via @m-mcgowan 's API but under the hood it would be as fast as it gets. @satishgn, I would love to see your propose implementation.

@m-mcgowan
Copy link
Contributor Author

We can expand with port writes as another PR. Is everyone happy with this as it is so it can be included for the imminent 0.4.2 release?

@pkourany
Copy link
Contributor

I agree, do as another PR

@technobly
Copy link
Member

Has anyone really tested this? Personally I have not had the time but really want to before we release it.

@ScruffR
Copy link
Contributor

ScruffR commented Jun 12, 2015

@technobly, tested what? Bit-banding or my portSetMasked()?
The latter is tested on the Core and the books tell that this should work on the Photon just the same, but I haven't tested it - due to lack if HW ;-)

@m-mcgowan, I'm fine with that 👍

@technobly
Copy link
Member

Tested the speed of inline functions setting and clearing GPIO, vs macros we are currently using. Anyone have a scope besides me?

@pkourany
Copy link
Contributor

@technobly, I have a scope and logic analyzer but I can only test late tonight or tomorrow. What did you test on (Core vs Photon) and what were the timings? Can you post your test code so I can duplicate?

@technobly
Copy link
Member

Easiest thing to do is look at v006 of the NeoPixel library with a scope. First verify my documented timings with a scope for WS2812B with Photon and Core, not logic analyzer. Then swap out the macros for these new inline functions. Appreciate the help Paul!

@m-mcgowan
Copy link
Contributor Author

Hi Everone, I'm preparing a 0.4.2 release, so going to merge this in. If any bugfixes are needed, we can discuss those as separate issues.

m-mcgowan added a commit that referenced this pull request Jun 13, 2015
@m-mcgowan m-mcgowan merged commit 8a3074a into develop Jun 13, 2015
@m-mcgowan m-mcgowan deleted the feature/fast_pin branch June 13, 2015 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants