ECSPI demo stop working in MCUXpresso Software Development Kit

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

ECSPI demo stop working in MCUXpresso Software Development Kit

805 Views
wenfu
Contributor III

I'm using M4 core's ESCPI in i.max8mq and I want to start with the follow example code:

boards\evkmimx8mq\rtos_examples\freertos_ecspi\ecspi_loopback

boards\evkmimx8mq\driver_examples\ecspi\ecspi_loopback

Both of the 2 demos just run a single test on SPI then hung up CPU, just send 64 bytes and get the data back from internal  loop. But the application scenario is to run SPI periodically. So I add a while(1) loop in the demo code, just like the following code segment. But the weird thing is the code stoped after several senonds. If I add the init function before transfer function the code can run all the time. Both the demo for RTOS and non-ROTS has the same issue.  Does it nessary to initialise SPI before every signle transfer?

static void ecspi_task(void *pvParameters){
    uint8_t i;
    status_t status;
    ecspi_rtos_handle_t master_rtos_handle;
    ECSPI_MasterGetDefaultConfig(&masterConfig);
    masterConfig.baudRate_Bps   = ECSPI_TRANSFER_BAUDRATE;
    masterConfig.enableLoopback = false;
    for (i = 0; i < ECSPI_TRANSFER_SIZE; i++)    { 
       masterTxData[i] = i;
    }    
while (1){        
if (status != kStatus_Success)        { 
           PRINTF("ECSPI meets error during initialization. \r\n");
            vTaskSuspend(NULL);
       }
        masterXfer.txData   = masterTxData;
        masterXfer.rxData   = masterRxData;
        masterXfer.dataSize = ECSPI_TRANSFER_SIZE;
        masterXfer.channel  = ECSPI_MASTER_TRANSFER_CHANNEL;        /*Start master transfer*/ 
       status = ECSPI_RTOS_Transfer(&master_rtos_handle, &masterXfer);
        if (status != kStatus_Success)
        {            
PRINTF("ECSPI transfer completed with error. \r\n\r\n");
            vTaskSuspend(NULL); 
       }        /* Compare Tx and Rx data. */ 
       for (i = 0; i < ECSPI_TRANSFER_SIZE; i++) 
       {            if (masterTxData[i] != masterRxData[i]) 
           {                break;           
 }        
}        
if (ECSPI_TRANSFER_SIZE == i)  
      {            
PRINTF("\r\nFreeRTOS ECSPI loopback test pass!");    
    }        else    
    {            PRINTF("\r\nFreeRTOS ECSPI loopback test fail!");     
   }    }  
  vTaskSuspend(NULL);
}
0 Kudos
3 Replies

531 Views
MBaer
Contributor II

Hi Wen

Could you solve your problem?

I have similar issues and I am intrested if there is a solution.

Best regards 

Marcel

0 Kudos

735 Views
wenfu
Contributor III

Hi 

I'm sure there's no place to call ECSPI_Deinit(). I just add a while(1) in the demo code, no more code was added. You guys can replicate it easilly.

B.R.

Wen

0 Kudos

735 Views
igorpadykov
NXP Employee
NXP Employee

Hi Wen

there is ECSPI_Deinit() function in ecspi_loopback.c, one can check if 

it is called somewhere.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos