imxrt 1064 evk communicating with an external device using SPI interface

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

imxrt 1064 evk communicating with an external device using SPI interface

1,339 Views
YH14
Contributor I

Hello,

I am new to NXP board programming and I am trying to connect my imxrt1064 evk to an external device (a sensor) using a SPI interface. I need to read the roll, pitch and yaw from the external sensor.  I have tried to follow the SDK examples using lpspi peripheral but the example is not very clear. Could anyone point me out in the right direction.

TIA

0 Kudos
6 Replies

1,323 Views
YH14
Contributor I

Hi Kerry,

Thank you for your response. I had tried this already but the slave is not responding with values. 

TIA

YH

0 Kudos

1,309 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi YH14,

  Thanks for your updated information.

   So, do you check the SPI bus wave, then compare it with your external device datasheet, whether that meets your external device SPI communication sequence or not?

  BTW, when you connect the SPI to your external device, you need to make sure your external device is power on at first, then the RT send the command to your external device, just make sure, when the RT send the SPI data to your slave, the slave is ready to receive it.

  Any updated information on your side, just kindly let me know.

Best Regards,

Kerry

0 Kudos

1,331 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi YH14,

   Welcome to use the NXP MIMXRT product, I would like to provide service for you.

  If you want to use the RT1064 LPSPI to connect your external sensor, you need to read your external sensor datasheet, check the SPI baudrate which it can accept, then the related control command.

  Then you can refer to this RT1064 SDK code:

SDK_2.9.1_EVK-MIMXRT1060\boards\evkmimxrt1060\driver_examples\lpspi\polling_b2b_transfer\master

masterConfig.baudRate = TRANSFER_BAUDRATE;//LPSPI baudrate.

When you want to connect the external sensor, you need to send the command to your sensor.

 You can put that command in the masterTxData, then use the following code to send out:

/*Start master transfer, transfer data to slave.*/
masterXfer.txData = masterTxData;
masterXfer.rxData = NULL;
masterXfer.dataSize = TRANSFER_SIZE;
masterXfer.configFlags =
EXAMPLE_LPSPI_MASTER_PCS_FOR_TRANSFER | kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap;

LPSPI_MasterTransferBlocking(EXAMPLE_LPSPI_MASTER_BASEADDR, &masterXfer);

You can try it on your side.

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

 

0 Kudos

1,281 Views
YH14
Contributor I

Hi Kerry,

I have made this sensor LSM9DS1 work with stm32 microcontroller with a specific settings. But I am unable to reproduce the same with NXP EVK 1064 using the LPSPI module. My questions are 

1) In the notes of the LPSPI module, it mentions I need to weld 0 ohm resistor. Is this mandatory to be done for LPSPI to work?

2) How can I use the logic analyser on the NXP board to see the clock and data signals? Right now I am not able to see it at all

3) Even after connecting the board to the sensor and following the procedure which you have mentioned, I am unable to see the data coming back from sensor. I have powered the sensor using 3V.

Any help will be appreciated.

TIA

YH

0 Kudos

1,270 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi YH14,

  Do you use the J24 related SPI pin? If yes, you must short R278,R279,R280,R281.

  You can check the schematic:

kerryzhou_0-1617677695914.png

It is DNP in default. Short it to test is very important.

Now answer your questions:

1) In the notes of the LPSPI module, it mentions I need to weld 0 ohm resistor. Is this mandatory to be done for LPSPI to work?

Answer: Use J24_3-6, you must short R278,R279,R280,R281. Otherwise, the RT chip LPSPI pin didn't rout to the J24 interface.

2) How can I use the logic analyser on the NXP board to see the clock and data signals? Right now I am not able to see it at all

Answer: Do you have Logic Analyzer, or the oscilloscope is also OK, you can check the related SPI pin wave, whether it has the SPI wave on the SPI bus or not.

3) Even after connecting the board to the sensor and following the procedure which you have mentioned, I am unable to see the data coming back from sensor. I have powered the sensor using 3V.

Answer:Check SPI bus wave, and check your STM32 SPI bus wave to your sensor, compare it.

 

Wish it helps you!

Any updated information, kindly let me know.

Best Regards,

Kerry

 

 

 

0 Kudos

1,272 Views
crist_xu
NXP Employee
NXP Employee

Hi, 

    I think you can check if the pcs pin is low when the transfer begin. or check the ACS value. Or it the clock is woring on the continue mode.

 

Regards,

   Crist

0 Kudos