2392897_en-US

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

2392897_en-US

2392897_en-US

SPI communication failed in DMA mode(S32k328)

A hardware error will occur when serial port output is attempted after calling the Rm_Init(&Rm_Config); function.

Comment out Rm_Init(&Rm_Config) and call  The status remains busy; I have only listed the key initialization functions.

        if (Lpspi5_ready_flag == 0u)
        {
            spi_status = Lpspi_Ip_AsyncTransmit(&LPSPI5_EXTERNAL_DEVICE,
                                                &Spi5TxBuffer[0],
                                                &Spi5RxBuffer[0],
                                                NUMBER_OF_BYTES,
                                                Spi5_EndCallback);
            if (spi_status != LPSPI_IP_STATUS_SUCCESS)
            {
                printf("SpiTp: AsyncTransmit FAIL\r\n");
                return;
            }
        }
static void system_init(void)
{
    /* Initialize Clock */
    Clock_Ip_StatusType Status_Init_Clock = CLOCK_IP_ERROR;
    Status_Init_Clock = Clock_Ip_Init(Clock_Ip_aClockConfig);
 
    /* Initialize all pins using the Port driver */
    Siul2_Port_Ip_PortStatusType Status_Init_Port = SIUL2_PORT_ERROR;
    Status_Init_Port = Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals,
    		g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals);

    /* Initialize interrupt */
    IntCtrl_Ip_Init(&IntCtrlConfig_0);
        /* Initialize Dma */
    IntCtrl_Ip_EnableIrq(DMATCD0_IRQn);
    IntCtrl_Ip_EnableIrq(DMATCD1_IRQn);
    Dma_Ip_Init(&Dma_Ip_xDmaInitPB);
    Dma_Mux_Ip_Init(&Dma_Mux_Config);
    //Rm_Init(&Rm_Config);

}
    /* Initialize each Spi hardware units using*/
    Lpspi_Ip_Init(&Lpspi_Ip_PhyUnitConfig_SpiPhyUnit_0_Instance_4);
    Lpspi_Ip_Init(&Lpspi_Ip_PhyUnitConfig_SpiPhyUnit_1_Instance_5);
    Lpspi_Ip_Init(&Lpspi_Ip_PhyUnitConfig_SpiPhyUnit_2_Instance_3);

    /* Update Framesize */
    Lpspi_Ip_UpdateFrameSize(&LPSPI4_EXTERNAL_DEVICE, 8U);
    Lpspi_Ip_UpdateFrameSize(&LPSPI5_EXTERNAL_DEVICE, 8U);
    Lpspi_Ip_UpdateFrameSize(&LPSPI3_EXTERNAL_DEVICE, 8U);

    /* Update Transfered Bit order */
    Lpspi_Ip_UpdateLsb(&LPSPI4_EXTERNAL_DEVICE, TRUE);
    Lpspi_Ip_UpdateLsb(&LPSPI5_EXTERNAL_DEVICE, TRUE);
    Lpspi_Ip_UpdateLsb(&LPSPI3_EXTERNAL_DEVICE, TRUE);

    /* Update Transfer Mode */
    Lpspi_Ip_UpdateTransferMode(LPSPI4_EXTERNAL_DEVICE.Instance, LPSPI_IP_INTERRUPT);
    Lpspi_Ip_UpdateTransferMode(LPSPI5_EXTERNAL_DEVICE.Instance, LPSPI_IP_INTERRUPT);
    Lpspi_Ip_UpdateTransferMode(LPSPI3_EXTERNAL_DEVICE.Instance, LPSPI_IP_INTERRUPT);
/* SPI5 AsyncTransmit 完成回调 */
static void Spi5_EndCallback(uint8 Instance, Lpspi_Ip_EventType Event)
{
    (void)Instance;

    if (Event == LPSPI_IP_EVENT_END_TRANSFER)
    {
        Spi5TransferOk    = TRUE;
        Spi5TransferFault = FALSE;
    }
    else /* LPSPI_IP_EVENT_FAULT */
    {
        Spi5TransferFault = TRUE;
        Spi5TransferOk    = FALSE;
    }

    Spi5TransferDone = TRUE;
}

Re: SPI communication failed in DMA mode(S32k328)

Hi, @VaneB

Based on your reply, I changed the RM configuration DMAMUX source to channel 16 and channel 17, and the DMA is also set to the corresponding channel 16 and channel 17.

1. I commented out

Rm_Init(&Rm_Config);

reserve

Dma_Mux_Ip_Init(&Dma_Mux_Config);

The interrupt was triggered normally.

2. I commented out

Dma_Mux_Ip_Init(&Dma_Mux_Config);

reserve

Rm_Init(&Rm_Config);

It will still trigger a hardware error.


It's working properly now. It would be perfect if this problem could be solved. Thank you so much!

BR, zyzzzz

Re: SPI communication failed in DMA mode(S32k328)

Hi @zyzzzz 

I have an observation regarding your configuration. You have configured LPSPI5 to use DMA; however, in the RM configuration, the DMA MUX sources assigned to Channel 0 and Channel 1 correspond to LPSPI_1, not LPSPI_5. 

Also, if you are already calling:

Dma_Mux_Ip_Init(&Dma_Mux_Config);

there is no need to also call:

Rm_Init(&Rm_Config);

Or vice versa. This is because Rm_Init() internally performs the following initialization sequence:

Rm_Init()
└─ Rm_InitGroup1()
   └─ Rm_Ipw_Dma_Mux_Init()
      └─ Dma_Mux_Ip_Init()

As a result, the DMA MUX is being initialized twice. I would recommend keeping only one initialization function. 


BR, VaneB

Re: SPI communication failed in DMA mode(S32k328)

Hi @zyzzzz 

I noticed that you are configuring the DMA channels using DMAMUX0. However, if you refer to the S32K3xx_DMAMUX_map.xlsx file included with the Reference Manual, you can verify that the LPSPI_5 DMA request is mapped to DMAMUX1, not DMAMUX0.

Please update the configuration to use DMAMUX instance 1 instead of instance 0.

Re: SPI communication failed in DMA mode(S32k328)

Hi, @VaneB

I'm glad to receive your reply. I understand what you mean, but DMAMUX instance 1 cannot be selected at this time.

If you select DMA_INSTANCE_0 and then select DMA Hardware Channel 16, you can select DMA Mux Source as DMA_MUX_1_LPSPI_5_TX_REQUEST.

Tags (1)
No ratings
Version history
Last update:
2 weeks ago
Updated by: