SPI Interrupt Problems

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
SaGh_4441651
Level 3
Level 3
First like received First like given

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 -

Capture1.JPG

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

Capture2.JPG

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

a) In cyapicallbacks.h

  #define SPI_1_SPI_UART_ISR_EXIT_CALLBACK

  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]

0 Likes
1 Reply
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi SaGh_4441651​,

I hope this is same as your previous thread SPI_Interrupt. I've given my latest comment in that thread. Please review that and let us move all our discussions to the other thread.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes