The sequence describes how process a data transfer through LPSPIx i.MXRT1170 master

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

The sequence describes how process a data transfer through LPSPIx i.MXRT1170 master

467 Views
flex
Contributor I

Could you please write in clear manner, step by step, as it was done for LPC17xx User manual, what is the sequence which describes how one should process a data transfer with the LPSPIx i.MXRT1170 when it is set up to be the master. 

I just want to remember how it was done for the LPC17xx on p.404:

" This process assumes that any prior data transfer has already completed.
1. Optionally, verify the SPI setup before starting the transfer.
2. Write the data to transmitted to the SPI Data Register. This write starts the SPI data
transfer.
3. Wait for the SPIF bit in the SPI Status Register to be set to 1. The SPIF bit will be set
after the last cycle of the SPI data transfer.
4. Read the SPI Status Register.
5. Read the received data from the SPI Data Register (optional).
6. Go to step 2 if more data is to be transmitted.

Note: A read or write of the SPI Data Register is required in order to clear the SPIF status
bit. Therefore, if the optional read of the SPI Data Register does not take place, a write to
this register is required in order to clear the SPIF status bit."

So resulting code may looks like that:

/* Send one byte then recv one byte of response. */
static uint8_t LPC17xx_SPI_SendRecvByte (uint8_t byte_s)
{
uint8_t byte_r;
 
LPC_SSP0->DR = byte_s;
while (LPC_SSP0->SR & (1 << SSPSR_BSY) /*BSY*/); /* Wait for transfer to finish */
byte_r = LPC_SSP0->DR;
 
return byte_r;                      /* Return received value */
}
 

From you awful Reference Manual for the i.MXRT1170 it's hard to understand something useful. Moreover, in the SDK examples doesn't exits any useful example for real SPI IC to be able to understand how to really program LPSPI and control 

0 Kudos
Reply
1 Reply

433 Views
Miguel04
NXP TechSupport
NXP TechSupport

Hi @flex 

I recommend you to review the evkmimxrt1170_lpspi_polling_b2b_transfer_master_cm7 example code from the i.MXRT1170's SDK 2.14.0.

The fsl_lpspi.c driver has the functions to initialize the peripheral and transfer data. For example:

LPSPI_MasterInit(...)

LPSPI_MasterTransferBlocking(...)

If you look into the driver, before the function you get a brief description to use it, also during the execution of the function you can find comments that clearly describes the process to follow.

Sorry for the inconvenience.

Best Regards,

Miguel.

 

0 Kudos
Reply