Config for SPI interrupts

cancel
Showing results for 
Search instead for 
Did you mean: 

Config for SPI interrupts

494 Views
stefanlindblad
Contributor I

Hi

I’m starting out with KL17Z64 and MCUXpresso. For a quick start I decided to use the Config Tool to generate initialization code for the peripherals.

For the SPI in interrupt mode the tool  generated this init function:

void SPI_1_init(void) {

  /* Enable interrupts */

  SPI_EnableInterrupts(SPI_1_PERIPHERAL, (kSPI_RxFifoNearFullInterruptEnable | kSPI_TxFifoNearEmptyInterruptEnable));

  /* Enable interrupt SPI0_IRQn request in the NVIC */

  EnableIRQ(SPI_1_IRQN);

  /* Initialization function */

   SPI_SlaveInit(SPI_1_PERIPHERAL, &SPI_1_config);

}

 

Looks like the functions are called in wrong order, SPI_EnableInterrupts() crashes as the clock for the SPI is enabled first in SPI_SlaveInit().

Regards,

Stefan

0 Kudos
2 Replies

260 Views
Lukas_Heczko
NXP Employee
NXP Employee

Hi Stefan,

this is indeed issue in SPI component in Peripherals tool. It affects also the FLEXCOMM variant of the SPI component used by LPC processors.

Attached please find patch fixing the issue in MCUXpresso Config Tools v5. Instructions how to apply the patch are included in the archive. This issue will be fixed in upcoming MCUXpresso Config Tools v6.

Thank you for reporting this issue and we apologizes for the inconvenience.

Regards,

Lukas  

0 Kudos

260 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Stefan Lindblad ,

Yes, the sequence is wrong,  the right sequence should like below:

void SPI_1_init(void) {

  /* Initialization function */
   SPI_SlaveInit(SPI_1_PERIPHERAL, &SPI_1_config);


  /* Enable interrupt SPI0_IRQn request in the NVIC */
  EnableIRQ(SPI_1_IRQN);

/* Enable interrupts */
  SPI_EnableInterrupts(SPI_1_PERIPHERAL, (kSPI_RxFullAndModfInterruptEnable | kSPI_TxEmptyInterruptEnable));

  /* Initialization function */

}

I will report it to development team. And now , I recommend you refer to the SPI demo under KL27 board,

pastedImage_4.png

Hope it helps,


Have a great day,
TIC

-------------------------------------------------------------------------------
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