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

SPI Inteface not working in nus_data_handler

I merged SPI, I2c into BLE_UART example, spi interface works fine in  main() function, but when i try to write spi memory with data received from BLE UART ( in nus_data_handler )then SPI does not works.

but same SPI routines works just fine in main()

Thanks

Kamal

Parents
  • Hi,

    Sounds like you could be having an interrupt priority issue. Are your SPI functions blocking inside the nus_data_handler to wait for the transfer to complete? This handler runs in interrupt context, possibly higher than the configured priority of your SPI peripheral. It is generally safer to do tasks that take some time in the main loop and not in interrupt context, to prevent the application from blocking other tasks. Set a flag in the handler and do the transfer in main when the flag is set.

    Best regards,
    Jørgen

Reply
  • Hi,

    Sounds like you could be having an interrupt priority issue. Are your SPI functions blocking inside the nus_data_handler to wait for the transfer to complete? This handler runs in interrupt context, possibly higher than the configured priority of your SPI peripheral. It is generally safer to do tasks that take some time in the main loop and not in interrupt context, to prevent the application from blocking other tasks. Set a flag in the handler and do the transfer in main when the flag is set.

    Best regards,
    Jørgen

Children
No Data
Related