1 Reply Latest reply on Nov 8, 2018 12:38 AM by user_13463998

    infinite loops

    FernandoMendoza

      What can it be when the function (while(0u == (nRF_SPI_GetMasterInterruptSource() & nRF_SPI_INTR_MASTER_SPI_DONE))) goes to infinite loops?

       

      void SPI_wait_done() {

        nRF_SPI_ClearMasterInterruptSource(nRF_SPI_INTR_MASTER_SPI_DONE); 

        while(0u == (nRF_SPI_GetMasterInterruptSource() & nRF_SPI_INTR_MASTER_SPI_DONE))

          ;  /* Wait while Master completes transfer */

       

       

          /* Clear interrupt source after transfer completion */

        nRF_SPI_ClearMasterInterruptSource(nRF_SPI_INTR_MASTER_SPI_DONE);

      }

        • 1. Re: infinite loops
          user_13463998

          Hi,

           

          I would do something like

          =============================

          int SPI_wait_done() {

            int result = OK ;

            uint32_t timeout = 0xFFFFFF ; /* some big number to wait */

           

            nRF_SPI_ClearMasterInterruptSource(nRF_SPI_INTR_MASTER_SPI_DONE);

           

            while(0u == (nRF_SPI_GetMasterInterruptSource() & nRF_SPI_INTR_MASTER_SPI_DONE)) {

               if (--timeout == 0) {

                    result = TIMEOUT ;

                    break ;

               }

            }

          ...

          =============================

          moto