Skip to content

attachInterrupt vs. SoftDevice #171

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Nenik opened this issue Aug 29, 2018 · 4 comments
Closed

attachInterrupt vs. SoftDevice #171

Nenik opened this issue Aug 29, 2018 · 4 comments

Comments

@Nenik
Copy link
Contributor

Nenik commented Aug 29, 2018

I have run into an issue when using GPIO interrupts.
If I call attachInterrupt() before Bluefruit.begin(), the Bluefruit.begin() fails with NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION, which I suspect might be related to the interrupt priority used by the attachInterrput() implementation.
Calling Bluefruit.begin() first, the interrupr callback works well.
This would really be worth documenting at least.
But should the change in the interrupt priority fix the issue, that would be even better.

@hathach
Copy link
Member

hathach commented Aug 29, 2018

Ah yeah, it is mentioned multiple times in the forum. Bluefruit.begin() enable sd, which will affect the vector table in some ways. Some irq may not work if called before that. We haven't looked into the details to resolve this, maybe later when we got more free time.

@hathach
Copy link
Member

hathach commented Sep 1, 2018

just for reference
image

Nenik added a commit to Nenik/Adafruit_nRF52_Arduino that referenced this issue Sep 1, 2018
Nordic SoftDevice needs to have control over lowest priority interrupts
for reliable, timing sensitive operation. If user code tries to use
such a low priority level, SoftDevice refuses to start.
One way to overcome this limitation is to start the SoftDevice before
attaching pin change interrupts, though in such a case, SD will
cap the effective priority of the user interrupt anyway and it is
a common mistake API users do. This change simply changes the priority
to 2, which is legal (for fast interrupt handlers anyway) under SoftDevice,
no matter if attached before of after SD start.
Nenik added a commit to Nenik/Adafruit_nRF52_Arduino that referenced this issue Sep 1, 2018
Nordic SoftDevice needs to have control over lowest priority interrupts
for reliable, timing sensitive operation. If user code tries to use
such a low priority level, SoftDevice refuses to start.
One way to overcome this limitation is to start the SoftDevice before
attaching pin change interrupts, though in such a case, SD will
cap the effective priority of the user interrupt anyway and it is
a common mistake API users do. This change simply changes the priority
to 2, which is legal (for fast interrupt handlers anyway) under SoftDevice,
no matter if attached before of after SD start.
@Nenik
Copy link
Contributor Author

Nenik commented Sep 1, 2018

Pull request: #179

hathach added a commit that referenced this issue Sep 5, 2018
Fix upstream issue #171: Better choice of pin interrupt priority
@hathach
Copy link
Member

hathach commented Nov 8, 2018

thanks for PR, this should be fixed already.

@hathach hathach closed this as completed Nov 8, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants