Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 3 months ago.
SPI read to KS8995 Ethernet chip always return FF
Hi,
I have connected KS8995 Ethernet switch to my Raspberry PI SPI. Ok. Trying to read the register of KS8995 using spi driver ioctl calls. I am using spidev_test.c program for that. I tried both /dev/spidev0.0 and /dev/spidev0.1, to read the register of KS8995 via SPI. It is always returning FF. Here is the code link for spidev_test.c https://github.com/KnCMiner/spi-test/blob/master/spi-test.c. I am giving input as [01, 02] to read registers 01 and 02. uint8_t default_tx[] = { 0x01, 0x02]
The output is alyways FF for any register. Could you please tell me where I going wrong.
Thanks Subbu.
1 Answer
7 years, 3 months ago.
Hi subbu. Not sure how this is related to mbed but, have you seen this webpage ?
https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
The Raspberry Pi is equipped with one SPI bus that has 2 chip selects. The SPI master driver is disabled by default on Raspbian. To enable it, use raspi-config, or ensure the line dtparam=spi=on is not commented out in /boot/config.txt, and reboot. If the SPI driver was loaded, you should see the device /dev/spidev0.0. The SPI bus is available on the P1 Header: MOSI P1-19 MISO P1-21 SCLK P1-23 P1-24 CE0 GND P1-25 P1-26 CE1
What is your pinout between the raspberry PI and your external SPI device ?
Are you sharing a common ground ?
External device is being powered correctly ?
If you do not have one already, consider to pick up a low cost SPI bus analyzer - many are available for under $ 10 USD and use the tool to assist to debug and observe the activity on the SPI port pins.