S32K3 SPI Transmit Data is Interrupted

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

S32K3 SPI Transmit Data is Interrupted

6,272 Views
YL005
Contributor III

Hi,

I'm developing SPI functions with S32K3 evaluation board and trying to send 9 commands in a row with 15 bytes per command without DMA involved. The MCAL used in this project is "SW32K3_RTD_4.4_2.0.2"

The SPI is working properly without receive CAN messages. But when the controller starts to receive CAN messages, the transmited SPI data seems to be interrupted frequently. (The interrupt priority of CAN is 5 and the SPI is 3.)

Can anyone tell me why this happened and how to identify which function the SPI is interrupted by.

 

Normal SPI Command

NormalSpiTransmit.png

Interrupted SPI command

InterruptedSpiTransmit.png

Thanks.

0 Kudos
10 Replies

6,250 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @YL005 

With the information you gave us, it seems that CAN may be interrupting the data transmission of SPI. To verify this, could you share your code with us so we can check it in detail?

 

B.R.

VaneB

0 Kudos

6,218 Views
YL005
Contributor III

Hi VaneB,

Sorry for the late reply. Sorry, I can't provide the code I used, because there is some information related to our project. But I can share the interrupt configuration with the priority of the CAN and SPI as the attached files. The CAN messages are received by CAN0 and SPI is transmitted by SPI5.

 

0 Kudos

6,213 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @YL005 

Can you elaborate more on how you are managing the SPI IRQ? Are you receiving/sending the SPI frame on the IRQ Handler or outside?

0 Kudos

5,967 Views
YL005
Contributor III

Hi,

I found out that another interrupt is also weird

The PIT notification should be called every 1ms, and I flip a 1ms flag in the callback function as follow

void Gpt_PitNotification_PIT0_CH0(void) {
    fs_f_us1msFastTask ^= 1;
}

The flag record by lauterbach as the figure attached.

YL005_0-1679390502839.png

 

In my point of view, I would say that there's someone has higher priority of the PIT or SPI.

Attached is the configuration of interrupts, I can't find any clue about it.

Please tell my if you have any further ideas.

Thanks a lot.

 

0 Kudos

5,955 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @YL005 

From the document, you shared only the interrupts of PIT0, FlexCan 1 to 5, LPSPI0 and LPSPI5.

One possibility is that PIT0, the one with the highest priority, should not be interrupted by another, but it could interrupt FlexCan and LPSPI.

Also, having so many interruptions, you must manage these well so they do not overlap.
What I suggest is to leave your project with the main peripherals and go together with the others to find at what point the problem is generated

0 Kudos

5,916 Views
YL005
Contributor III

Hi @VaneB,

Thanks for your advice.

I have a further question about the interrupt of SPI.

In the post below I notice that I setup the "asynchronous mode" but sent the SPI data with "Synchronout mode". Can you tell where can I find the example of transmit SPI data with asynchronous mode?

0 Kudos

5,855 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @YL005 

Included in the RTDs are examples of LSPI.

0 Kudos

6,114 Views
YL005
Contributor III

Sorry for lately reply.

I use the following API to initial the SPI driver.

/* Initialize the Spi driver */
Spi_Init(NULL_PTR);
/* Set Spi mode */
Spi_SetAsyncMode(SPI_INTERRUPT_MODE);

Then use the following API to send and receive SPI command.

Spi_SetupEB(SpiConf_SpiChannel_SpiChannel_HostSPI, TxChBuf, receiveData, 15u);
statusHost = Spi_SyncTransmit(SpiConf_SpiSequence_SpiSequence_Host);

0 Kudos

6,096 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @YL005 

According to the information you provided me, I can see that you are using synchronous and asynchronous communication functions. Are you using both types of communication?

0 Kudos

5,970 Views
YL005
Contributor III

No, the transmit API I used in runtime is synchronize only


statusHost = Spi_SyncTransmit(SpiConf_SpiSequence_SpiSequence_Host);

0 Kudos