can't read from SPI Beagleboard xm

Hi all,

I have a problem with SPI; I can write and see what I have written on
the scope, but in reading I get zeros all the time.
I don't know where the problem is.

my configuration is as follows:
I am using Beagleboard xm revision B, with kernel version 2.6.32
downloaded from TI.
http://software-dl.ti.com/dsps/dsps_public_sw/sdo_tii/TI_Android_DevKit/02_00_00/index_FDS.html

for pin multiplexing: I have disabled OMAP_MUX from the Kernel, and
now I am using U-Boot to configure the pins.
the configuration for SPI3 and 4:

MUX_VAL(CP(MMC2_CLK), (IDIS | PTU | DIS | M1)) /* MCSPI3_CLK - O/P -
MODE1*/\
MUX_VAL(CP(MMC2_CMD), (IDIS | PTU | DIS | M1)) /*MCSPI3_SIMO - O/P -
MODE1*/\
MUX_VAL(CP(MMC2_DAT0), (IEN | PTU | EN | M1)) /*MCSPI3_SOMI - I/P
- MODE1 - PULLUP*/\
MUX_VAL(CP(MMC2_DAT2), (IDIS | PTU | DIS | M1)) /*MCSPI3_CS1 - O/P -
MODE1*/\
MUX_VAL(CP(MMC2_DAT3), (IDIS | PTU | DIS | M1)) /*MCSPI3_CS0 - O/P -
MODE1*/\

MUX_VAL(CP(MCBSP1_CLKR), (IDIS | PTD | DIS | M1)) /*MCSPI4_CLK - O/P
- MODE1*/\
MUX_VAL(CP(MCBSP1_DX), (IDIS | PTD | DIS | M1)) /*MCSPI4_SIMO - O/P
- MODE1*/\
MUX_VAL(CP(MCBSP1_DR), (IEN | PTU | EN | M1)) /*MCSPI4_SOMI - I/P
- MODE1 - PULLUP*/\
MUX_VAL(CP(MCBSP1_FSX), (IDIS | PTD | DIS | M1)) /*MCSPI4_CS0 - O/P
- MODE1*/\

I use very close example like spidev_test.c in Kernel documentation.
http://rswiki.csie.org/lxr/http/source/Documentation/spi/spidev_test.c

Also I tried to connect MCSPIx_SOMI with pin 1 which is 1.8v all the
time expecting to read 0XFF instead of zeros, but this also didn't
work.

any suggestions ...

Hi,

I have a problem with SPI; I can write and see what I have written on
the scope, but in reading I get zeros all the time.
I don't know where the problem is.

for pin multiplexing: I have disabled OMAP_MUX from the Kernel, and
now I am using U-Boot to configure the pins.
the configuration for SPI3 and 4:

MUX_VAL(CP(MMC2_CLK), (IDIS | PTU | DIS | M1)) /* MCSPI3_CLK - O/P - MODE1*/\

MUX_VAL(CP(MCBSP1_CLKR), (IDIS | PTD | DIS | M1)) /*MCSPI4_CLK - O/P - MODE1*/\

You must configure SPI clocks as input, not output. Don't ask why :slight_smile:
Posts by Ben Gamari propably will help you:
  http://groups.google.com/group/beagleboard/msg/8aee29983db18133

"The CLK pins must be put in input mode for the chip to correctly register input on SOMI. Failure to set CLK as an input will result in all reads producing zeros"
  BeagleBoard/SPI - eLinux.org

The reason is, that IDIS and IEN is not a switch between input and output only modes, but a switch between output only and bidirectional mode.

The input on the clock line is neccessary, because the same clock is used as a timing reference for the MISO data.

Bjoern

It worked fine after I changed IDIS to IEN, Thanks a lot guys.
Please accept my apology for the late response.

hi islam,

I have read all the writings on the subject on the Internet. I did all the steps but neither i read the data nor i write the data.Can you throw a mail if possible,explaining the steps you did?

just read →

root@beagleboard:~# spitest -D /dev/spidev4.0

spi mode: 0
bits per word : 8
max speed…

00 00 00 00

best regards.