Configure SPI communication on S32K148EVB-Q176

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

Configure SPI communication on S32K148EVB-Q176

1,730 Views
marco_roma
Contributor I

Hello, we are very new to this world, and we are trying to configure the evaluation board S32K148EVB-Q176 in order to read data via SPI or I2C from a steval MKI178v1 imu.

We read datasheet and many more documentation but we are not able to find the correct way to do that (we never worked with ebmedded architecture). We ask you to give us any suggestions or any guide about hardware configuration and coding for the software implementation. Any help will be appreciated, thank you!

Labels (1)
0 Kudos
3 Replies

1,526 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello marco.roma@student.unife.it,

This is a very general post. But please use the SDK examples that are available in the S32 Design Studio first, then get familiar with the SPI and I2C specifications and reconfigure the Masters according to the datasheet of the sensor (LSM6DSL). 

pastedImage_4.png

BR, Daniel

0 Kudos

1,526 Views
marco_roma
Contributor I

Thank you danielmartynek for answer me; yes you are right, the question is very generic because I've different kind of troubles, but let me be more specific, then.

That is exactly what I'm trying to do, but I'm supposed to write low level code, and that's not exactly what I can see from the examples.

First of all, I found something more studying libraries' implementation and surfing the internet, but it's not clear which is the correct "routine" that should be implemented: how can I set the correct mode? should I write the register address and then the data? How can I do it?

To be clear, the most similar thing I found is this: HMC5883L triple axis magnetometer interfacing with LPC2148 | ARM7..  but I didn't found anything about the equivalent registers of the S32K148EVB, I found no documentation about the list of command bytes and registers of the EVB, unlike the IMU that have some description of its registers in the datasheet. How does this program work? When I write the byte in the correct register, what makes it shift from the master to the slave? Does it happens automatically after the initialization of SPI?

I found also this: https://pdfserv.maximintegrated.com/en/an/AN4184.pdf that is a different way to work, but controlling the single pins seems to me not a good alternative, how can the clock be a real clock for example?

And I found also this very interesting: https://www.nxp.com/docs/en/application-note/AN5413.pdf but I can't understand where it writes the data byte, given the fact that no address is written (should I write the correct address and then the correct byte in the same way? How does the slave know when I'm writing a register address or a byte to be written there?) . Which pins does it use? Why does it says:

     * Pin number        | Function
     * ----------------- |------------------
     * PTB14             | LPSPI1_SCK
     * PTB15             | LPSPI1_SIN
     * PTB16             | LPSPI1_SOUT
     * PTB17             | LPSPI1_PCS3

if in the documentation https://www.nxp.com/docs/en/quick-reference-guide/S32K148EVB-QSG.pdf  it says in HMI mapping that:

SBC_SCK - PTA28(LPSPI1_SCK)

SBC_MISO - PTA29(LPSPI1_SIN)

SBC_MOSI - PTA27(LPSPI1_SOUT)

SBC_CS - PTA26(LPSPI1_PCS0)  ?

And another problem is... where is PTA26 that seems to be mentioned only here?

Thank you in advance for any help, I hope I've been more clear. 

Best Regards, Marco

0 Kudos

1,526 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,
The cookbook (AN5413) is a good staring point.
But the routines must be built as per the datasheet of the sensor.
It is LSM6DSL, I believe
https://www.st.com/resource/en/datasheet/lsm6dsl.pdf
6.4 SPI bus interface

Yes, the LPSPI module of the S32K1xx MCU shifts the send data automatically.
pastedImage_1.png
In the cookbook example, the format of the SPI transfer is configured by the LPSPI1_init_master() function, mainly by the LPSPI1->TCR transmit command register.
Please read Chapter 49 Low Power Serial Peripheral Interface (LPSPI) in the S32K1xx RM.

The cookbook example is using these pins:
pastedImage_3.png
Connect them to the sensor and scope them.

Regarding this:
SBC_SCK - PTA28(LPSPI1_SCK)
SBC_MISO - PTA29(LPSPI1_SIN)
SBC_MOSI - PTA27(LPSPI1_SOUT)
SBC_CS - PTA26(LPSPI1_PCS0)

These are the pins that are connected to the on-board SBC chip.

Regards,
Daniel

0 Kudos