8 years ago.

SPI (slave mode) and BLE on nRF51822

I'm trying to put together a SPI (slave) <-> BLE bridge with a nRF51822. My problem is that if I call BLE::startAdvertising() (after setting up everything BLE-related), then the SPI reception stops after a random period of time (I'm continously sending data to it, but that's not forwarded over BLE). SPISlave::receive() returns 0 no matter what I send to it. My guess is that something gets messed up with interrupts. I'm not touching interrupt handling in any way in my code. Here's my main loop:

while(true) {
    ble.processEvents();
    if(run_cnt++ == 100000) {
        run_led = !run_led;
        run_cnt = 0;
    }
    if(spi.receive()) {
        if(comm_cnt++ == 1000) {
            comm_led = !comm_led;
            comm_cnt = 0;
        }
        spi.reply(0);
    }
}

I'm blinking two LEDs, one to see if the main loop is running (run_led) and one to indicate SPI reception (comm_led). After a random amount of time, comm_led stops blinking while run_led continues.

Does anyone have an idea how to get SPI slave mode and BLE working at the same time?

Be the first to answer this question.