SPI 1-Byte data Write and Read

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

SPI 1-Byte data Write and Read

跳至解决方案
4,068 次查看
SadaK
Contributor II

I'm using LPC55S06-EVK. I have downloaded SDK_2_12_0_LPCXpresso55S06.  

As per development kit connection, I'm using the following 4 MCU pins for SPI interface.

  • Pin-59: SCK SPI_FLASH_PIO0_6
    Pin-55: MOSI SPI_FLASH_PIO0_3
    Pin-57: CS SPI_FLASH_PIO0_4
    Pin-54: MISO SPI_FLASH_PIO0_2

I'm using ADXL345 as a SPI slave device.

Question:

Which command to use for 1-byte data Write & Read?

--------------------------------------------------

SPI-Write:

Byte-0 = 0x00 (MOSI, Command/Address. Output from MCU)

Byte-1 = 0x55 (MOSI, Write 1-byte data. Output from MCU)

 

SPI-Read:

Byte-0 = 0x80 (MOSI, Command/Address. Output from MCU)

Byte-1 = 0xXX (MISO, Read 1-byte data. Input to MCU)

 

ADXL345's SPI timing waveform attached

0 项奖励
回复
1 解答
4,017 次查看
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

I recommend use an example of the SDK from the MCU [spi_interrupt_b2b_transfer_master] then in the library fsl_spi.h you can find some functions to write and read. If you are searching for a command to read and write the part of ADXL it will show it in the datasheet of this part.

Pavel_Hernandez_0-1661281843498.png

In the SDK you will found some examples.

Pavel_Hernandez_1-1661282013471.png

Best regards,
Pavel

 

在原帖中查看解决方案

4 回复数
4,031 次查看
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

I review your case, unfortunately, this does not represent an NXP issue, I suggest reviewing the datasheet from the ADXL part, I think it will show you what command is for reading and writing, or in another way contact the vendor.
Then when you have this information you can structure the frame in the example from the LPC.

Best regards,
Pavel

0 项奖励
回复
4,024 次查看
SadaK
Contributor II

Hi,

I have already tested ADXL345 part with STM32 MCU’s using STM32CubeIDE. It works great. As I explained in the initial post. I would like to know how to write & read registers from MCUXpressoIDE using LPC55S06-EVK

I know what data to be written from NXP MCU to access ADXL registers. Those details provided below.

--------------------------------------------------

SPI-Write: 

Byte-0 = 0x00 (MOSI, Command/Address. Output from MCU)

Byte-1 = 0x55 (MOSI, Write 1-byte data. Output from MCU)

 

SPI-Read:

Byte-0 = 0x80 (MOSI, Command/Address. Output from MCU)

Byte-1 = 0xXX (MISO, Read 1-byte data. Input to MCU)

0 项奖励
回复
4,018 次查看
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

I recommend use an example of the SDK from the MCU [spi_interrupt_b2b_transfer_master] then in the library fsl_spi.h you can find some functions to write and read. If you are searching for a command to read and write the part of ADXL it will show it in the datasheet of this part.

Pavel_Hernandez_0-1661281843498.png

In the SDK you will found some examples.

Pavel_Hernandez_1-1661282013471.png

Best regards,
Pavel

 

4,012 次查看
SadaK
Contributor II

Thanks, this helps..!