SPI 1-Byte data Write and Read

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

SPI 1-Byte data Write and Read

Jump to solution
3,305 Views
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 Kudos
Reply
1 Solution
3,254 Views
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

 

View solution in original post

4 Replies
3,268 Views
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 Kudos
Reply
3,261 Views
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 Kudos
Reply
3,255 Views
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

 

3,249 Views
SadaK
Contributor II

Thanks, this helps..!