LPSPI on S32K144 timeout problem

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

LPSPI on S32K144 timeout problem

2,312 Views
thomaserdmann
Contributor I

Hello,

i have a question to lpspi on s32k144.

I am using the eval board and connected a nxp ncj3320e nfc reader chip to lspci on ptb0=ss,ptb2=sck,ptb3=miso,ptb4=mosi.

Calling a transfer LPSPI_DRV_MasterTransferBlocking() for up to 2 bytes performs correct.

Calling it for 8 bytes always gives me a TIMEOUT error.

The timeout parameter for the call is 1000 (ms) and the spi clock rate ist 500kHz.

What to do ?

Doing some call with only 1 byte is not a solution because of the toggeling of the select line.

0 Kudos
5 Replies

1,524 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi Thomas,

I tried to reproduce your issue, but the transfer looks fine. Please check the attached project.

Your application call other interrupts during SPI transfer? Can you share the project which reproduce this possible issue?

Best regards,

Razvan

1,524 Views
migsantiago
Contributor I

Thanks Tilimpea. I had an issue where I could not see any activity on the SPI lines and the transfer function was timing out. I checked your attachment and I missed the function to initialize the pinout:

PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

0 Kudos

1,524 Views
thomaserdmann
Contributor I

If i split the LPSPI_DRV_MasterTransferBlocking() into the non blocking call and then do a LPSPI_DRV_MasterGetTransferStatus() i always get that several bytes were not received but all are transmitted.

The number of bytes for rx and tx are here always the same and i assume that rx and tx must complete the same time even if there is no activity on the miso pin. miso pin seems to be correctly assigned to lpspi0 in "processor expert".

The status function also delivers "BUSY" return status continuously.

status_t spi_nfc_transfer( const uint8_t * tx, uint8_t * rx, uint16_t n ) {
  status_t sts=LPSPI_DRV_MasterTransfer( LPSPICOM0NFC, tx, rx, n );
  while( sts==STATUS_SUCCESS ) {
    uint32_t nbytes;
    LPSPI_DRV_MasterGetTransferStatus( LPSPICOM0NFC, &nbytes );
    if( !nbytes ) break;
    //OSIF_TimeDelay( 1 );
  }
  return sts;
}

0 Kudos

1,524 Views
wjandsq
Contributor IV

bsp_lpspi.c 

/*!
* SPI_Flash_Send_Byte
* @brief W25Q64/W25Q128
*
*/
void SPI_Flash_Send_Byte(uint32_t instance, uint8_t *TxData, uint8_t *RxData, uint16_t count)
{
    LPSPI_DRV_MasterTransfer(instance, TxData, RxData, count);

#if defined (LPSPICOM1)

    if (instance == LPSPICOM1) {
        xSemaphoreTake( BinarySem_LPSPI1_TxHandle, portMAX_DELAY);

    }

#endif
}

lpspi_master_driver.c

/*!
* @brief Check if errors are detected on RX channel
* The main purpose of this function is to check DMA errors on rx channel
*/
static void LPSPI_DRV_MasterCompleteRX(void* parameter, edma_chn_status_t status)
{
#if defined (LPSPICOM1)
    static portBASE_TYPE xHigherPriorityTaskWoken;
    xHigherPriorityTaskWoken = pdFALSE;
#endif

    uint32_t instance = (uint32_t)parameter;
    lpspi_state_t * lpspiState = g_lpspiStatePtr[instance];

    if (status == EDMA_CHN_ERROR)
    {
        (void)LPSPI_DRV_MasterAbortTransfer(instance);
        lpspiState->status = LPSPI_TRANSMIT_FAIL;
    }
#if defined (LPSPICOM1)
    if (instance == LPSPICOM1) {
        xSemaphoreGiveFromISR( BinarySem_LPSPI1_TxHandle, &xHigherPriorityTaskWoken);
        portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
    }
#endif
}

0 Kudos

1,524 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

There might be problem with the nfc reader. Because the function expects to receive 8 bytes and waits in busy state until timeout. I assume it receives only two bytes.

 

Regards,

Daniel

0 Kudos