SPI Slave IRQ not working on NHS3152

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI Slave IRQ not working on NHS3152

Jump to solution
1,605 Views
SilabS
Contributor II

Hello everyone,

wanted to make an SPI Slave which is Interrupt based on NHS3152. I have used the code from app_example_dp_ssp and ssp_nss_example1 and ssp_nss_example2 to form my simple code. I just want when the data is sent from other device to receive an interrupt. But when I do send data from another device (the device is functioning properly, proved by logic analyzer) I do not get any reaction on my NHS3152. I do not get any SPI interrupt generated nor the code jumps into interrupt by debugging.

Here is the code used.

void SSP0_IRQHandler(void)

{

//do something

}

int main()

{

Chip_IOCON_Init(NSS_IOCON);
Chip_IOCON_SetPinConfig(NSS_IOCON, (IOCON_PIN_T) IOCON_PIO0_6, IOCON_FUNC_1);
Chip_IOCON_SetPinConfig(NSS_IOCON, (IOCON_PIN_T) IOCON_PIO0_2, IOCON_FUNC_1);
Chip_IOCON_SetPinConfig(NSS_IOCON, (IOCON_PIN_T) IOCON_PIO0_8, IOCON_FUNC_1);
Chip_IOCON_SetPinConfig(NSS_IOCON, (IOCON_PIN_T) IOCON_PIO0_9, IOCON_FUNC_1);


Chip_SSP_Init(NSS_SSP0);
Chip_SSP_SetMaster(NSS_SSP0, false);
Chip_SSP_SetFormat(NSS_SSP0, SSP_BITS_8, SSP_FRAME_FORMAT_SPI, SSP_CLOCK_MODE0);
Chip_SSP_SetBitRate(NSS_SSP0, NHS3152_SPI_BIT_RATE);
// Chip_SSP_SetClockRate(NSS_SSP0, NHS3152_SPI_BIT_RATE, 1);

 

Chip_SSP_ClearIntPending(NSS_SSP0, SSP_INT_CLEAR_BITMASK); // not sure about this one, maybe has to be called from the interrupt handler?!
Chip_SSP_Int_Enable(NSS_SSP0);
Chip_SSP_Enable(NSS_SSP0);


NVIC_ClearPendingIRQ(SSP0_IRQn);
NVIC_EnableIRQ(SSP0_IRQn);

// while (!Chip_SSP_GetStatus(NSS_SSP0, SSP_STAT_TFE)) {
// ; /* wait */
// }

}

 

Thank you in advance.

Labels (1)
  • RF

0 Kudos
Reply
1 Solution
1,515 Views
driesmoors
NXP Employee
NXP Employee

Hi,

Yes, just add SSP_RXIM in the bits to be set.

Thus the implementation becomes:

/**
 * Enable interrupt for the SSP
 * @param pSSP : The base address of the SSP peripheral on the chip
 */
static inline void Chip_SSP_Int_Enable(NSS_SSP_T *pSSP)
{
    pSSP->IMSC |= SSP_RXIM | SSP_TXIM;
}:

 

Best,
Dries.

View solution in original post

4 Replies
1,577 Views
SilabS
Contributor II

Hello @Kan_Li . Thank you, your answer explains some things.

Still, is there any possibility to enable an SPI slave to raise an interrupt upon receiving data on NHS3152?

0 Kudos
Reply
1,516 Views
driesmoors
NXP Employee
NXP Employee

Hi,

Yes, just add SSP_RXIM in the bits to be set.

Thus the implementation becomes:

/**
 * Enable interrupt for the SSP
 * @param pSSP : The base address of the SSP peripheral on the chip
 */
static inline void Chip_SSP_Int_Enable(NSS_SSP_T *pSSP)
{
    pSSP->IMSC |= SSP_RXIM | SSP_TXIM;
}:

 

Best,
Dries.

1,570 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hello @SilabS ,

 

Yes, it is possible, The RXIM bit is used for that purpose.

nhs spi rx int.png

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
1,593 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hello @SilabS ,

 

This issue is due to you didn't enable the RX interrupt by "Chip_SSP_Int_Enable(NSS_SSP0);", please read the following source code for details.

nhs3152 interrupt spi.png

Hope that helps,

 

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------