SPI Read Data Problem

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

SPI Read Data Problem

976 Views
umershah81
Contributor II

Hi hope you all are doing good.  i'm already done with spidev_test and thats working well, i can send and receive the data. but the problem is when i read the data from arduino uno r3 or Lora (SPI interface module). all receive data is currupted or damaged. i don't know whats going on is it hardware problem or a coding problem. 

please share your experience. 


here is the Pyhton code:

===========================================

import spidev
import time
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 500000
spi.mode = 0b11
try:
while True:

resp = spi.readbytes(3) #spi.xfer([0xAA])#readbytes(3)
if (resp[0] != 255):
#print(''.join(["0x%02X " % x for x in resp]).strip())
value = resp[1] + resp[2]
print(value)
byte1 = bin(resp[0])[2:].rjust(8,'0')
byte2 = bin(resp[1])[2:].rjust(8,'0')
byte3 = bin(resp[2])[2:].rjust(8,'0')
bits = byte1 + byte2 + byte3
print(bits)
time.sleep(0.05)
except KeyboardInterrupt:
spi.close()

========================================================

OUTPUT :
510
111111011111111111111111
=========================================================================

and if i use linux spidev_test to read data from arduino i get 

FF FF FF 7F FF FF FD FF
FF FF 7F FF FF FE FF FF
FF DF FF FF FF FF FF FF
CF FF FF FF FF FF FF FB
FF FF FF FF FF FF

THANKS 

Labels (1)
0 Kudos
2 Replies

864 Views
umershah81
Contributor II

thanks brother,

Actually, i enabled spidev in kernel config manually but while compiling through bitbake it replaces the config with default. 
i solved it buy editing config using bitbake.

864 Views
gusarambula
NXP TechSupport
NXP TechSupport

Hello Syed Bukhari,

My recommendation would be using the Pins Tool for i.MX, which provides a GUI that allows you to see the available muxing options for each module and it also generates the code for the device tree.

You can download it from the link below on the Downloads section:

https://www.nxp.com/design/designs/pins-tool-for-i.mx-application-processors:PINS-TOOL-IMX

I hope this helps!

Regards,

0 Kudos