how to use beaglebone black read data from LS7366R via SPI?

37 views
Skip to first unread message

Dong Dianbiao

unread,
Mar 20, 2018, 6:21:02 AM3/20/18
to BeagleBoard
I'm doing a project with DC motors. Then I use the beaglebone black connecting with a encodercounter of LS7366R to read the encoder data of the DC motor. while when I send command to this chip. I only get 255 return. the coder is shown as following. anyone knows how to fix it? the LS7366R board is from here LS7366R board


from Adafruit_BBIO.SPI import SPI

import time

spi=SPI(0,0)
spi.msh=10000
spi.bpw=8
spi.threewire=False
spi.lsbfirst = False
spi.cshigh = False
spi.open(0,0)

spi.xfer2([0x88,0x03])#set the counter to 4bytes mode


#read back data
try:
  while True:
encoderCount=spi.xfer2([0x60,0x00,0x00,0x00,0x00])
       


        print encoderCount
        sleep(0.2)

except KeyboardInterrupt:
        spi.close()
        print  "all done"

Reply all
Reply to author
Forward
0 new messages