This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Does SPI read work inside ble_event_handler or timer_handler ?

Hello ! Can I read with SPI registers without any problems from inside a ble_event_handler or a timer_handler or should I expect to have problems due to interrupt priorities and so forth ?

  • You most likely will run into problems. I had an issue with reading from SPI inside event handlers which I assume was related to interrupt priorities.

    In order to avoid this issue, you can use a scheduler to run the SPI reads in main context instead of interrupt context. That way, you can schedule functions (such as a SPI read function) to happen in your main loop after the BLE event has been handled.

  • Hello ! Thank you for your answer. The problem was the breaboard I was using :)) I tried with the scheduler and it works better because I set value 0 to some bytes that I do not use and with the scheduler they remain 0, but without scheduler they get weird values sometimes.