3 Replies Latest reply on Dec 5, 2018 11:48 PM by PY_21

    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

          • 2. Re: infinite loops
            PY_21

            Hello,

             

            The API nRF_SPI_GetMasterInterruptSource() will returns Master interrupt request register. This register contains current status of Master interrupt sources. The master interrupt source nRF_SPI_INTR_MASTER_SPI_DONE will describe that SPI master transfer is completed.

            The function (while(0u == (nRF_SPI_GetMasterInterruptSource() & nRF_SPI_INTR_MASTER_SPI_DONE))) goes to infinite loops when the SPI master transfer is not completed.

             

             

            Thanks,

            P Yugandhar.

            • 3. Re: infinite loops
              PY_21

              Please refer the PSoC4 Serial communication Block(SCB) Component for more information in the below link.

              http://www.cypress.com/file/220331/download

               

              Thanks,

              P Yugandhar.