This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to execute another task while processor in __WFE? Bare Metal SPI (nrfx_spim)

Hello! 

is it possible to execute some code in the section
  

  APP_ERROR_CHECK(nrfx_spim_xfer(memory_structure->spi_Instance, &spi_xfer_Descript, 0));
     while (memory_structure->spi_xfer_done==false)
     {
        __WFE();
     }

or do i have to implement some kind of thread logic? or any kind of nonRTOS library? 

I come from FreeRTOS development and I want to manage the idle time in a bare metal app that has to wait for sensor data

Board: NRF52 pca10040

  • Hi,

    Her you are calling __WFE() in the while loop. So the CPU goes to sleep an at any point when it wakes up it will continue from there (after processing any interrupts). So you need to do this differently if you want the CPU do do some tasks while waiting.

    The typical way of achieving this is to have a main loop in your application which enters sleep (for instance by calling __WFE()) in every iteration. Then any tasks you want to be done in the main context (not interrupt) is done from there. You would also need to change how you wait for spi_xfer_done to be true, so that instead of looping you call an event handler or something when that happens, so that you avoid a waiting loop anywhere.

Related