I connected MOSI to MISO on Raspberry PI 3
Executed the below code:
import time
import sys
import spidev
spi = spidev.SpiDev()
spi.open(0,0)
print(spi.bits_per_word)
print(spi.mode)
print(spi.max_speed_hz)
ret = spi.xfer2([0x1, 0x2, 0x3, 0x4])
print (ret)
I am getting a different output data than what I send:
pi@raspberrypi:~/spi $ python3 spi.py
8
0
125000000
[0, 1, 1, 2]
May I know the reason, why is the input data not same as the output?
Update:
setting the speed to 30 MHZ worked.spi.max_speed_hz = 30000