SPI Interface with LS1043ARDB

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

SPI Interface with LS1043ARDB

455 Views
TrinathK
Contributor III

Hi all,

       I have written my sample application code in SPI probe function and i am transmitting 4 bytes of data (0x12, 0x34, 0x56, 0x78). When i see the output of 1st byte (i.e; 0x12) on CRO, its last data bit is not proper. (Refer Image in the attachment).

Note :

Pink waveform : CS

Yellow : SPI CLK

Blue : MOSI  (Data : 0001 0010)

As we can see,

For 1st 3 clocks, data is 0

For 4th clock, data is 1

For 5th and 6th clocks, data is 0

For 7th clock, data is 1

For 8th clock, data is half 0 and half 1.

 

I am using LS1043ARBD board, linux version 5.4.47 and spidev.c as my driver.

My application code is present in spi probe function which is attached for your reference.

Please help me resolve this issue. Thanks in advance.

Trinath K.

0 Kudos
1 Reply

440 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to "transfer" function provided in Documentation/spi/spidev_test.c

static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
{
int ret;

struct spi_ioc_transfer tr = {
.tx_buf = (unsigned long)tx,
.rx_buf = (unsigned long)rx,
.len = len,
.delay_usecs = delay,
.speed_hz = speed,
.bits_per_word = bits,
};

if (mode & SPI_TX_QUAD)
tr.tx_nbits = 4;
else if (mode & SPI_TX_DUAL)
tr.tx_nbits = 2;
if (mode & SPI_RX_QUAD)
tr.rx_nbits = 4;
else if (mode & SPI_RX_DUAL)
tr.rx_nbits = 2;
if (!(mode & SPI_LOOP)) {
if (mode & (SPI_TX_QUAD | SPI_TX_DUAL))
tr.rx_buf = 0;
else if (mode & (SPI_RX_QUAD | SPI_RX_DUAL))
tr.tx_buf = 0;
}

ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);

if (ret < 1)
pabort("can't send spi message");

if (verbose)
hex_dump(tx, len, 32, "TX");
hex_dump(rx, len, 32, "RX");
}

0 Kudos