Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years ago.
Can't mbed on nRF51822 detect GPIO interrupt?
Hi all
I'm useing a mbed working on nRF51822 and want to use GPIO interrupt. However, it doesn't work. Are there any problem my codes or API? I checked my circuit works correctly.
My source code is like following:
- include "mbed.h"
- include "ble/BLE.h"
InterruptIn int_pin(p19);
int flag = 0;
void rise_up() { flag = 1; }
void main() { int_pin.rise(rise_up); while(1){ if(flag){ something } } }
The rise_up function never be called.
Then, I read this thread: https://developer.mbed.org/questions/53958/Does-mbed-library-makes-nRF51822-interru/
In this thread, Tim said: Try removing the bluetooth code and checking if it works. It might be that the BLE interrupts are blocking yours. In that case there is not much you can do about it. Edit: actually if you just want to count edges you can do this entirely in hardware using PPI and the TIMER module.
Is this API problem still existing?
Best regards
1 Answer
9 years ago.
I don't know if your device can do interrupts on every pin. However for sure you need to define flag as volatile to make it work.