Project

General

Profile

spi mode error

Added by Brian Wentworth over 7 years ago

I'm trying to uses the hps spi controller and am getting an error trying to set the spi mode. I'm using spidev and when I run this code:

ret = ioctl(fd, SPI_IOC_WR_MODE, SPI_MODE_1);
if (ret == -1)
pabort("can't get spi mode");

and I get this error:

can't get spi mode: Bad address
Aborted

Any idea on this?
Thanks,
Brian


Replies (5)

RE: spi mode error - Added by Brian Wentworth about 7 years ago

I have not been able to get this to work. Does anyone have any idea why this is happening?
Thanks,
Brian

RE: spi mode error - Added by Michael Williamson about 7 years ago

Is your file descriptor, fd, valid?

RE: spi mode error - Added by Brian Wentworth about 7 years ago

Yes I can send and receive using : ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
but only in spi mode 0x0. If I try and set the spi mode using the command above I get the pavort error.

RE: spi mode error - Added by Michael Williamson about 7 years ago

I think the SPI_IOC_WR_MODE is looking for the argument to be an address pointer (char*) pointing to the SPI_MODE_1 value.

Can you try:

char mode = SPI_MODE_1;
ret = ioctl(fd, SPI_IOC_WR_MODE, &mode);

that would account for the bad address error code....

RE: spi mode error - Added by Brian Wentworth about 7 years ago

This solved the error but there is no change to the spi mode.

    (1-5/5)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)