1 Reply Latest reply on Nov 7, 2019 1:31 AM by BragadeeshV_41

    SPI Interrupt Problems


      I have a PSOC 4100S Plus. I am trying to setup the SPI communication. I have a SCB block that I have set up as a SPI Master. I need to do 2 different things on 2 different interrupts.

      1) Do certain thing when the TX buffer is empty

      2) Do certain thing when the SPI Master is done transferring the byte

      I also need to enable/disable the respective interrupts at certain times


      For this I have done the following things -

      1) In the PSoC Creator, set up the SCB Block as Master with the following configuration -


      2) I have the internal interrupts enabled but I have not selected any particular interrupt sources as I want to enable and disable them at run time


      3) I set up the ISR to handle each of these interrupts like this -

      a) In cyapicallbacks.h



        void SPI_1_SPI_UART_ISR_ExitCallback(void);


      b) And my SPI_1_SPI_UART_ISR_ExitCallback() defination is as such -


      void SPI_1_SPI_UART_ISR_ExitCallback()


        if( 0u != (SPI_1_GetTxInterruptSource() & SPI_1_INTR_TX_EMPTY ))


          //Application Function to be called here

          SPI_1_ClearTxInterruptSource( SPI_1_INTR_TX_EMPTY );  


        if( 0u != (SPI_1_GetMasterInterruptSource() & SPI_1_INTR_MASTER_SPI_DONE ))


          //Application Function to be called here

          SPI_1_ClearMasterInterruptSource( SPI_1_INTR_MASTER_SPI_DONE );




      I am facing 2 problems as soon as I enable the SPI_1_INTR_TX_EMPTY-

      1) If I have any code in the exit callback as above, my not able to debug using the Jlink. When I try to download the code, I am getting this error - "Cannot read register 15 while CPU is running."


      2) When the ExitCallback funtion is empty like this

      void SPI_1_SPI_UART_ISR_ExitCallback(){ },


      the code is constantly stuck in this exit callback function. Looks like the SPI Interrupt is constantly occurring.


      What am I missing? What else needs to be done while using the SPI_1_INTR_TX_EMPTY  and  SPI_1_INTR_MASTER_SPI_DONE  interrupt sources? [I am unable to share my entire application code here]