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.
Solved! Go to Solution.
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.
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?
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.
Hello @SilabS ,
Yes, it is possible, The RXIM bit is used for that purpose.
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.
-------------------------------------------------------------------------------
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.
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.
-------------------------------------------------------------------------------