9 years, 1 month ago.

setSampleFrequency interferring with BLE connection/disconnection callbacks

Hi,

I'm using PinDetect to fire callback functions if a button is pressed/released. I'm running as a BLE Gatt server, and have callbacks on connection/disconnection of other BLE devices. I also have a ticker running every second to return the ble.waitForEvent().

I've setup PinDetect in main.cpp:

/*Setup switch input*/
    pIn.mode(PullUp);
    // Delay for initial pullup to take effect
    wait(.01);    
    //set asserted = 0 volts and deasserted = 5
    pIn.setAssertValue(0);
    // Setup Interrupt callback function for a button hit
    pIn.attach_asserted(&buttonPressed);
    pIn.attach_deasserted(&buttonReleased);    
    // Start sampling pb input using interrupts
    pIn.setSampleFrequency(); 

Everything works until I return one of the BLE onConnection or onDisconnection callbacks, at which point my mBed board freezes.

If I comment out pIn.setSampleFrequency() the BLE stuff works fine, but I don't get the PinDetect functionality.

It thus appears to me as though the callbacks are interfering with each other, or something strange is happening in setSampleFrequency. Any ideas as to why I can't make these two work simultaneously? - I might be doing something stupid!

Many thanks

Question relating to:

InterruptIn style DigitalIn debounced with callbacks for pin state change and pin state hold. debounce, DigitalIn, InterruptIn
Be the first to answer this question.